LOS ANGELES — Adrian Gonzalez singled home the winning run in the 10th inning to give the Los Angeles Dodgers a 3-2 victory over the San Francisco Giants on Thursday night.
The Dodgers reduced their magic number to five for clinching their first NL West title since 2009. They won for the seventh time in eight games against the rival Giants, a stretch that began with a three-game home sweep June 24-26.
The loss ended last-place San Francisco's streak of four consecutive winning seasons.
Carl Crawford opened the 10th with a single off Jeremy Affeldt (1-5). Pinch-hitter Nick Punto sacrificed Crawford to second before Gonzalez stroked a single into center field for the Dodgers' eighth walk-off win of the season.
Brian Wilson (2-1) earned the win after pitching against his former teammates for the first time since spending seven seasons in San Francisco, where he was part of two World Series championship teams. He tossed one scoreless inning of relief.
Affeldt was activated from the disabled list before the game.
Gregor Blanco's RBI single off Dodgers closer Kenley Jansen tied the score 2-all in the ninth. Jansen allowed a leadoff single to Pablo Sandoval. He was replaced by pinch-runner Juan Perez, who stole second and advanced to third on a passed ball by catcher Tim Federowicz.
The Giants threatened in the eighth when they loaded the bases before Hunter Pence hit into an inning-ending double play.
Dodgers starter Zack Greinke allowed one run and four hits in six innings. He struck out five and walked two in his second straight no-decision.
Giants starter Matt Cain gave up two runs — one earned — and six hits in seven innings. The right-hander struck out five and walked one in his second start since coming off the disabled list after missing 14 games with a bruised right forearm.
Los Angeles took a 2-1 lead with two outs in the seventh. Yasiel Puig doubled to deep left-center, scoring pinch-runner Dee Gordon, who came in after A.J. Ellis hit a leadoff single. Gordon stole second and was sacrificed to third by Mark Ellis.
The Dodgers tied it at 1 on a grounder by Mark Ellis in a messy second for the Giants that included a throwing error by Cain.
Greinke reached on an infield single to third after Sandoval slipped fielding the ball.
San Francisco led 1-0 on Pence's home run leading off the second.
NOTES: Dodgers SS Hanley Ramirez left in the seventh for precautionary reasons with mild tightness in his left hamstring. ... Affeldt missed the previous 50 games with a left groin strain. ... Three of the four games in the series are sold out. ... Dodgers co-owner Magic Johnson celebrated his bobblehead night with former Lakers teammates Michael Cooper and Mychal Thompson.