The defeat left the Dodgers two games behind St. Louis with only one game left in the regular season. Los Angeles had won six in a row to stay in the race for the second NL wild-card spot, but Mark Ellis lined out to center field with a runner on second base to end it.
The defending World Series champion Cardinals claimed the final berth in this year's major league playoffs. St. Louis will be at Atlanta on Friday in a one-game matchup to see which team advances to the division round.
Zito won his seventh straight decision, Buster Posey and Joaquin Arias homered and the NL West champion Giants finished off their longtime rivals.
The Dodgers knew early in their game that Cincinnati had beaten St. Louis 3-1, opening the door for them to remain in the chase. But they couldn't capitalize, and will miss the playoffs for the third straight season and first under the club's new ownership, including Magic Johnson and Mark Walter, who watched from their box.
Zito (15-8) continued his best stretch since joining the Giants in 2007. They've won his last 11 outings as the left-hander has gone 7-0 for the first time since he won eight in a row with Oakland from June 28-Aug. 4, 2005.
The former AL Cy Young winner allowed two runs and six hits in six-plus innings, struck out six and walked one to put himself in contention for a start in the NL division series.
Sergio Romo got three outs in the ninth to earn his 14th save in 15 chances after Jeremy Affeldt gave up a leadoff single to Andre Ethier that had Dodgers fans on their feet to end the game. Pinch runner Dee Gordon stole second with two outs on a close play, but Ellis hit a liner that center fielder Angel Pagan charged in to catch.
Chris Capuano (12-12) gave up two runs and five hits in three-plus innings, his shortest outing of the season. He allowed both home runs and didn't record any strikeouts or walks. The left-hander has lost five straight decisions against the Giants and fell to 1-7 in 13 career games against them.
The Dodgers rallied to trail 4-3 in the seventh on A.J. Ellis' two-run homer off Guillermo Mota, who came on after Zito hit Ethier in the back to start the inning.
Ellis pumped his right arm as he rounded first base and the crowd of 42,473 erupted. After pinch-hitter Nick Punto struck out looking, Mark Ellis doubled to deep center, but was thrown out trying to stretch it into a triple.
That proved costly as Shane Victorino tripled, and was stranded when slugger Matt Kemp struck out swinging against George Kontos to end the inning, slamming his bat to the ground. Kemp was hitless in four at-bats, with three strikeouts.
Posey led off the second with his 24th homer. The Dodgers answered right back, tying the game at 1 on Luis Cruz's RBI groundout to third base after Hanley Ramirez tripled in the bottom of the inning.
Arias homered leading off the third, giving the Giants a 2-1 lead. In the fourth, Dodgers fans cheered when the video board displayed the final score of the St. Louis game.
The Giants added two runs in the fifth on Marco Scutaro's RBI double in the right field corner off Jamey Wright, extending his hitting streak to a career-best 19 games, longest in the majors this season. Pagan, who walked leading off, beat the throw home to make it 4-1.
NOTES: The last time the Giants won 10 or more consecutive starts by one of their pitchers was when they won 11 in a row when Bill Swift started from April 6-June 27, 1992. ... The last time San Francisco lost one of Zito's starts was on Aug. 2 against the New York Mets. ... Posey started at first base after mild back spasms forced him out of Monday's game in the eighth inning. ... Dodgers 1B Adrian Gonzalez singled in the sixth, extending his hitting streak to 14 games, tops on the club. ... The Giants, who dropped the opener on Monday, haven't lost two straight road games since July 7-8 at Pittsburgh. ... RHP Clayton Kershaw will start Wednesday's season finale for LA. ... Dodgers great Maury Wills, an instructor for the team during spring training and the regular season, turned 80.
More Sports Headlines
Seahawks hope to address offense's slow starts Farquhar falters again in M’s 4-2 loss Coca-Cola calls on Blatter to resign Appeals court says lower court must reconsider Solo case Mís notebook: Cano to have sports hernia surgery after season Schmid, Keller to enter National Soccer Hall of Fame together Rain at Dover washes out qualifying; Kenseth on pole Ex-football star Irving Fryar sentenced to 5 years in prison
Our new comment system is not supported in IE 7. Please upgrade your browser here.