LOS ANGELES -- Giants left-hander Madison Bumgarner befriended Dodgers ace Clayton Kershaw a year ago when the two were running early sprints on the field at Dodger Stadium. On Friday, Bumgarner topped Kershaw to pick up a rare victory.

The Giants rallied in the seventh and held on in a tight ninth inning, beating Kershaw and the Dodgers 4-2. The win was just Bumgarner's second since the All-Star break, despite a 2.47 ERA during that span.

"I was happy for Bum as much as anybody," manager Bruce Bochy said. "It was good to get him a win."

The Giants rarely come away with anything but disappointment after facing Kershaw, who was 11-4 with a 1.32 ERA against the Giants in 21 previous appearances. But Bumgarner kept the Giants in the game until they could rally.

In his first matchup with Dodgers rookie slugger Yasiel Puig back in June, Bumgarner gave up an opposite field home run and afterward said he couldn't believe Puig managed to reach the outside pitch. On Friday, Bumgarner went after the rookie slugger with a clear plan, busting Puig inside with a steady stream of fastballs. Bumgarner threw five fastballs to Puig in the first inning, striking him out on one that was clocked at 94 mph.

"It's worked out in my favor the last couple of times," Bumgarner said of the matchup. "That's one thing with this game. There are constant adjustments."

The Dodgers had two walks and two singles through the first three innings but failed to score. Bumgarner struck out two in the fourth and worked out of a tight spot in the fifth. With two outs and a runner on second, Bumgarner again fed Puig a couple of 93 mph fastballs and got a fly out to left.

Bumgarner was every bit Kershaw's equal through the fifth, but the Giants left-hander ran into trouble in the sixth. Michael Young reached on a grounder to deep short and the Dodgers went up 2-0 when Juan Uribe rocketed an elevated fastball into the left field seats.

Uribe was making his first start in the cleanup spot since June 28, 2010, when he hit fourth for the Giants in a game against the Dodgers. Juan Perez kept a third run from scoring when he made a spectacular diving catch on the left field warning track, and the Giants immediately set to work erasing the lead.

Hunter Pence and Pablo Sandoval opened the seventh with back-to-back singles and Joaquin Arias drove in a run with a single to left-center field. Kershaw had gone 13 starts against the Giants without giving up more than two runs, a streak that dated back to May 18, 2011. But Brett Pill put the Giants up 3-2 when he reached down and poked a two-run single down the right field line.

"You know you're going to get at least one pitch to hit," Pill said. "I just tried put the barrel on it and then you hope that good things happen."

The Dodgers put runners on the corners in the bottom of the seventh but failed to score. In the top of the eighth, Pence padded the lead with a solo homer to right-center of Chris Withrow, Pence's fifth homer in the last 10 games.

After big contributions from Jean Machi and Javier Lopez, Sergio Romo closed the Dodgers out in the ninth, getting the final out with runners on the corners.

"It got a little scary there the last couple of innings," Bochy said. "I've been happy with the way the guys are playing. They're fighting hard. They did last night, and they did tonight. This is the time of year you do find out about guys."

  • Bochy and third base coach Tim Flannery were standing on the warning track during early batting practice Friday when former Giants closer Brian Wilson jogged by.

    "I did talk to Brian a bit," Bochy said. "I wanted to make sure he knew I was happy that he was back pitching. I know it was a long road for him."

    Wilson spent more than a year rehabbing after his second Tommy John surgery and signed with the rival Dodgers in August. On Thursday, in his first appearance against the Giants, Wilson pitched a scoreless 10th inning and picked up his second win.

    "I used to face them in spring training," he told local reporters on Friday. "It was another team. You've got to get three outs. I didn't really put added pressure or any emotion into the inning. I go out there, do my job and get it over with."

  • Right-hander Chad Gaudin (carpal tunnel syndrome) threw about 30 pitches in a simulated game and will be re-evaluated on Saturday. Gaudin has not pitched since Aug. 16.

    ON A1
    Barry Bonds' legal team
    strikes out again.

    Saturday's game
    Giants (Tim Lincecum 9-13) at L.A. Dodgers (Ricky Nolasco 13-9), 6:10 p.m. NBCBA