Two games remain in the regular season. The Dodgers must win both and St. Louis must lose both to force a one-game playoff between the clubs to be played Thursday at Dodger Stadium.
That unforgiving equation is a testament to how the guys got into this mess. Even in victory, a team that once had a 7 1/2-game lead can't ignore the obvious.
"It's satisfaction along with frustration," catcher A.J. Ellis said of the must-win urgency. "Obviously, we're not out of it and you have to be optimistic and positive. But at the same time you think of what could have been, what we could have done as players."
Ellis said the team's late surge coincides with a spirited team meeting last week.
"We had a pretty tough meeting down in San Diego and [Mattingly] laid it out for us," Ellis said. "He called us all on the carpet and put us on a spot where we had to take our own personal accountability for what was going on. It was a good meeting, and since that, guys have looked at themselves a little bit stronger than where we were before. I give a lot of credit to him.
"The onus is on us to be a little more accountable for what was going on with our struggles. Our inability to do anything to stop it, we were just rolling with it. I'm disappointed with how I handled it. I could have done more to turn this around."
Ellis, who gunned down the potential go-ahead run in the top of the ninth inning, was in the middle of the winning rally. It started when Ramirez singled off Santiago Casilla, was bunted to second by Shane Victorino and was singled to third by Luis Cruz, with third-base coach Tim Wallach holding Ramirez.
Ellis worked a 3-0 count and was walked intentionally to load the bases and bring up Herrera, who lined a single off the glove of drawn-in second baseman Marco Scutaro.
"I've never done something like that," Herrera said of his first Major League walk-off hit.
Andre Ethier slugged a two-run homer for the Dodgers in the fourth inning and Aaron Harang outpitched Giants ace Matt Cain, but the Dodgers bullpen couldn't protect the one-run lead.
"If there is time, hope or an opportunity for us to get in, we're going to exhaust every avenue to get it done," said Ethier. "It shows a lot of what this team is made up of. Hopefully it's not too late and not for nothing. I think with a little bit of luck and breaks on our side and us keeping up what we need to do, we'll figure out a way to get in and make this right and make a good run."
Harang allowed one run on two hits and was removed after six innings and 91 pitches. He finished the season with a 3.61 ERA, lowest of his career. In the last 10 games, Dodgers starters have a 1.24 ERA, and for the season, the staff leads the league in team ERA.
"It seems like with this team throughout the year it's been somebody else stepping up every night," said Harang. "I know we went through that tough spell and it seemed like the energy has really picked up this past week since we were down in San Diego."
Mattingly went with Ronald Belisario in the seventh inning to face the middle of San Francisco's batting order, and he escaped a two-on, two-out jam by striking out Brandon Crawford.
Kenley Jansen was next to work his way into a jam, and he didn't escape. Angel Pagan doubled with one out in the eighth. Scutaro stepped out of the batter's box as Jansen was about to unleash a 2-1 pitch. Plate umpire Jerry Layne didn't call time out, but he didn't call Jansen for a balk, either, when he didn't let go of the pitch.
"The umpire right away said he apologized," said Jansen. "He just called time really late."
Jansen was upset enough with the situation that catcher Ellis and pitching coach Rick Honeycutt met him on the mound. When play resumed, on the first pitch, Scutaro singled home Pagan to tie the game.
"Just missed my spot," said Jansen, dismissing the suggestion that he was affected by the non-call.
"We want to knock them out," said Pagan. "That's what we want. We want to get them out of the playoffs."
Brandon League allowed a two-out pinch-single in the ninth to Aubrey Huff, but Ellis erased pinch-runner Emmanuel Burriss trying to steal second.
"He's going to go," said Ellis. "I played against him for many years in the Minor Leagues, and he's a phenomenal basestealer and you have to be extra alert. It looked like he didn't get the best jump."
San Francisco had the early lead. Harang issued a one-out walk to Scutaro in the first inning and MVP candidate Buster Posey doubled Scutaro home with two outs.
The Dodgers got the lead from Cain in the fourth inning. Mark Ellis led off with a single that was trapped on a diving attempt by center fielder Pagan. Andre Ethier launched the next pitch into the bleachers, his 20th homer for a team-high 89 RBIs.
Gonzalez extended his hitting streak to 13 games with a single and added his 47th double, a career high, in the sixth inning. Following the double, Ramirez was walked intentionally and Victorino singled, but Gonzalez was thrown out at the plate by left fielder Xavier Nady.