The Padres were looking for a season-high third win a row. Instead, they fell to a Major League-worst 4-11 on the road.
Greene slammed a 101-mph fastball over the wall in right-center with two outs in the eighth to erase a 3-2 deficit.
Cashner had fanned seven of the previous 11 batters he faced this season. He had not been scored upon in the last six innings.
All that changed, thanks to Greene.
"It was a good pitch, it was down and away," Cashner said. "That's the pitch I wanted to make. He just put a good swing on it."
San Diego manager Bud Black agreed.
"It was a fastball away and it looked like it was headed for the outside corner," Black said.
Greene came up to the plate with an aggressive mindset.
"A guy like that, you've got to be ready to hit," Greene said. "He throws hard. I was fortunate enough to get something."
The drive helped erase a late rally by the Padres, who scored twice off Cardinals closer Jason Motte to take a 3-2 lead in the eighth. Jesus Guzman doubled in two runs with two outs. Chris Denorfia started the rally with a double.
Yonder Alonso, who has hit safely in 20 of his last 23 games, drew a walk to set the stage for Guzman's heroics. Guzman had been in a 1-for-13 slump until he broke out with two late hits Monday.
"I tried to hit the ball hard somewhere," Guzman said. "It was a fastball. I just saw the ball and tried to make contact."
Guzman's performance was not the only bright spot for the Padres in defeat. Starter Clayton Richard turned in his second consecutive quality start after five consecutive losses. He allowed two runs on seven hits over 7 1/3 innings and sailed through the first six innings, nursing a 1-0 lead.
Richard closed out his outing with a flourish, striking out Carlos Beltran to begin the eighth.
At that point, Black went to the usually-reliable Cashner, who missed most of the 2011 season with a rotator cuff strain.
Richard wanted to stay in the game, but realized that Black usually knows best.
"I was pleading my case," Richard said. "He wasn't biting. You can't blame him. [Cashner] has been terrific and he'll continue to be terrific. It was one of those days where one pitch changes the game."
The Padres took a 1-0 lead into the second inning on a single by Alonso and a sacrifice fly by catcher Nick Hundley. Richard appeared set to make that lone run stand. He did not allow a runner to get past second base over the first six innings.
But the Cardinals scored two runs on two hits in the seventh to go up for the first time, 2-1. Richard surrendered a costly infield hit to fellow lefty Jaime Garcia, who allowed two runs on seven hits over seven innings. Ironically, Richard had a key hit on Sunday -- a two-out pinch-hit single in the 13th inning -- that led to a 3-2 win over the Angels.
On Monday, the shoe was on the other foot. Garcia's hit put runners on first and third with one out. Rafael Furcal followed with a single to tie the score at 2-2. The go-ahead run came in on a groundout by Matt Carpenter.
Alonso and Guzman led an eight-hit attack with two each. Alonso has 32 hits in his last 87 at-bats and leads all NL rookies with a .301 average.
Guzman moved his average up nine points to .266 with a 2-for-4 effort.
"We fought the whole game," Guzman said. "Tomorrow is another day."