LOS ANGELES (AP) -- - With two strikes on him, Adrian Gonzalez kept looking for something he could hit.
He found it on the seventh pitch of his at-bat, singling 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.
It was Gonzalez's second game-ending hit this season and the eighth of his career, helping the Dodgers win in extra innings for the second time in two days.
''I take it just like any other at-bat with runners in scoring position,'' he said. ''Not try to get too big on any pitch.''
The Dodgers reduced their magic number to five for clinching their first NL West title since 2009. They won for the sixth time in seven 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), activated from the disabled list before the game.
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.
''Carl is pretty fast,'' Gonzalez said. ''I knew he was going to go all the way.''
The Dodgers' ritual celebration awaited Gonzalez, who had his jersey torn off as the crowd cheered.
''That's one of the reasons we want home-field advantage in the playoffs,'' he said.
Brian Wilson (2-1) earned his second win with the Dodgers 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.
''It's obviously different hitting him instead of catching him, but just looking at the velocity of the cutter and the fastball, it's pretty close to where he always is,'' Giants catcher Buster Posey said.
Wilson tossed a shutout inning, and he's thrown scoreless relief in 10 of his 11 appearances this season.
''I didn't do anything,'' he said, breezing past reporters on his way out after 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.
Jansen's first blown save since June 29 against Philadelphia ended his streak of 18 successful conversions.
''I'm not really worried about his stuff,'' Dodgers manager Don Mattingly said.
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.
''He hit the ball a little harder than I thought he did and I thought I had to jump to catch it, so that kind of changes the timing a little bit,'' Cain said. ''But that's not an excuse. That's a play that should be made.''
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: Gonzalez reached 90 RBIs for the seventh straight season. ... The Dodgers improved to 10-5 in extra-inning games, including 5-1 at home. ... Dodgers SS Hanley Ramirez left in the seventh for precautionary reasons with mild tightness in his left hamstring. Mattingly said Ramirez appeared to be slower than normal, and the shortstop complained to the trainer that he was hurt. ... Affeldt missed the previous 50 games with a left groin strain. ... The crowd of 53,393 was the largest paid attendance in the majors this season. ... 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.