Los Angeles entered Tuesday trailing St. Louis by two games with as many to play for the NL's second wild card. Cincinnati beat St. Louis 3-1 earlier in the evening, but the Dodgers' 4-3 loss to the Giants officially eliminated them from postseason contention.
A.J. Ellis hit a two-run homer in the seventh inning to pull Los Angeles within one, and it had the tying run on second base in the ninth before Ellis lined out to center.
"It doesn't feel that good right now," Ellis said.
The Dodgers (85-76) had won their previous six games to remain in contention for their first playoff berth since 2009, but they couldn't overcome St. Louis despite adding Hanley Ramirez, Adrian Gonzalez and Josh Beckett to the roster after the All-Star break.
"Everything kind of comes to a screeching halt," manager Don Mattingly said. "To not have that opportunity to move forward is painful."
MVP candidate Buster Posey helped West champion San Francisco (94-67) dash its bitter rivals' playoff hopes by going 2 for 4 with a solo homer.
"We're not so much into knocking people out," manager Bruce Bochy said. "There's a lot of history between these two clubs. Both clubs have knocked each other out."
Posey is hitting .337 with 24 homers and 102 RBIs and is all but assured of becoming the first catcher to the win the NL batting title since Ernie Lombardi in 1942.
It's possible Posey will get the day off to rest up for the postseason, plus he's 6 for 31 (.194) lifetime off Clayton Kershaw, who will oppose Giants starter Ryan Vogelsong for the fourth time this season Wednesday.
Kershaw (13-9, 2.58 ERA) allowed two earned runs in 27 innings in September and appears likely to finish as the NL ERA leader for a second straight year. The reigning Cy Young Award winner struck out 10 in eight innings of Friday's 8-0 win over Colorado.
He's only 2-3 over his last seven starts despite a 1.47 ERA, a stretch which began when he gave up two runs and fanned 10 in eight innings of a 2-1 loss to San Francisco on Aug. 20.
The left-hander has a 1.74 ERA in four starts against the Giants this year but has lost three of them. He's 7-4 in 15 career starts versus San Francisco, receiving more than two runs of support only three times.
Vogelsong (14-9, 3.46) beat San Diego in each of his last two outings, allowing one run in six innings each time. The right-hander had gone 2-4 with a 10.31 ERA in his previous seven outings.
He's been solid versus the Dodgers this season, going 2-1 with a 0.89 ERA in three starts -- opposing Kershaw in each outing.
Vogelsong gave up two runs -- one earned -- in six innings in the most recent matchup July 29, but Kershaw tossed a five-hitter in Los Angeles' 4-0 victory.
San Francisco has won six of the last eight meetings, including four of five at Chavez Ravine. The Giants lead this season series 10-7 and now look to record their most wins over the Dodgers in one year since going 13-6 in 2003.
Copyright 2012 by The Associated Press
This story is from ESPN.com's automated news wire. Wire index
MORE MLB HEADLINES
- Yankees get 3B Headley in trade with Padres
- Angels won't limit ace Richards' workload
- Ryu, Dodgers 1st to have 3 11-game winners
- Jones' 2 homers power Orioles past Angels