SAN FRANCISCO -- Bruce Bochy had it all mapped out: If Buster Posey could somehow reach base as the leadoff hitter in the bottom of the ninth inning, he would dispatch the speedier Gregor Blanco as a pinch runner.

Posey saved his manager the trouble.

He blasted a pitch into the left-field seats for his first career walk-off hit, giving the Giants a 2-1 victory over the Los Angeles Dodgers at AT&T Park on Friday night.

And Posey could handle that trotting around the bases just fine, thanks.

"We don't hit a lot of home runs," Bochy said. "But they're coming at a great time."

Posey's fourth homer of the season, off a full-count pitch from reliever Ronald Belisario, marked the seventh time this season that the Giants had hit a tying or go-ahead home run after the eighth inning.

This homer also came after all looked doomed: Dodgers starter Clayton Kershaw was as electric as always in this ballpark, carrying a no-hitter into the sixth inning and surrendering just one run over seven innings.

But the Giants stuck around, in part because starter Barry Zito also delivered a solid, if odd, start. The left-hander allowed the leadoff man to reach in all six innings he started, but only one of those runners scored. Kershaw, who led off the fifth inning with a double, came home on Nick Punto's single.

That's the way it stayed until the sixth, when the Giants finally broke through against Kershaw, one of their all-time tormentors. Marco Scutaro broke up the no-hitter with a one-out triple to right-center field and scored when Posey doubled to a similar location.

Posey was thrown out at the plate by center fielder Matt Kemp while trying to score on the Hunter Pence single that followed. But he would make it home eventually, thanks in part to five Giants relievers who kept the score 1-1 after Zito's departure in the sixth.

"Barry, that's a credit to him. He kept his poise out there. He gave us what we needed with a great effort," Bochy said. "And then the bullpen kept it close. That's the only way you win games like that."

Posey's home run was the first walk-off homer by a Giant since Nate Schierholtz on July 6, 2011, against San Diego.

Kershaw was pitching for the first time since being reinstated from the bereavement list after the death of his father. He now has a 0.73 ERA in nine career games at AT&T Park. Overall against the Giants, Kershaw has a 1.27 ERA, the best all-time by a San Francisco opponent with at least 50 innings pitched.

"He has been hard on us, I know that," Bochy said, "but that says a lot more about his talent than it does about our hitters."

  • Before the game, the Giants recalled outfielder Francisco Peguero from Triple-A Fresno and optioned catcher Hector Sanchez to Triple-A. Sanchez was just 3 for 20 this season with one RBI.

    "Sanchez needs to play," Bochy said. "He missed quite a bit in spring training and hasn't been playing much here, so we want to get him going, get some at-bats down there."

    Peguero batted .415 with two home runs and 14 RBIs for the Grizzlies.

  • Dodgers shortstop Hanley Ramirez suffered a left-hamstring injury and needed help off the field after getting thrown out at third in the sixth inning. Ramirez started this season on the disabled list because of a thumb injury suffered during a World Baseball Classic game at AT&T Park.

    This was just the fourth game for Ramirez since being activated Monday.

  • Shortstop Brandon Crawford was out of the starting lineup, leaving Pence as the only Giants player to start every game this season.

  • The Giants also reinstated left-handed reliever Jeremy Affeldt (strained right oblique) from the 15-day disabled list. He took the roster spot of right-hander Sandy Rosario, who was optioned to Fresno after Wednesday's game.

  • Dodgers cleanup hitter Adrian Gonzalez was a late scratch because of neck stiffness.

  • This was Metallica Night at AT&T Park, a thrill for lead singer James Hetfield, who lives in the Marin area and is a big fan of all the Bay Area teams. "You turn around and all of a sudden, hey, someone else is in the playoffs," Hetfield said. "It's great. Year-round torture."