LOS ANGELES (AP) - Cody Ross hit a tiebreaking three-run homer in the ninth inning, and the San Francisco Giants rebounded from the Dodgers' three-run rally in the eighth for an 8-5 victory over Los Angeles on Wednesday night.
Juan Uribe hit a two-run double and scored the tying run on James Loney's single during the Dodgers' dramatic two-out rally in the eighth against Giants closer Brian Wilson (4-1).
Ross then pulled a pitch by Lance Cormier (0-1) inside the left-field pole for just his third homer of the season for the first-place Giants.
San Francisco has won eight of 11 - losing its previous two in Colorado and briefly falling behind the Rockies in the NL West standings.
Miguel Tejada drove in two runs in the Giants' highest-scoring performance since April 18. San Francisco scored more than four runs for the first time in two weeks while beating its biggest rivals for the third straight time.
Matt Kemp homered for the Dodgers, who have lost four of five.
The Dodgers' rally in the eighth against Wilson, who had converted 12 straight save opportunities, erased a stellar start by Matt Cain, who allowed three hits while pitching into the eighth inning.
Cain outdueled Clayton Kershaw while extending his scoreless streak against Los Angeles to 20 innings, retiring the first 12 Dodgers before Kemp homered leading off the fifth inning.
Kershaw gave up seven hits and four runs in five innings for the Dodgers. He had pitched 26 1-3 consecutive scoreless innings against the Giants until they hit three consecutive two-out singles in the third inning, including Freddy Sanchez's RBI single, before a three-run rally in the fourth.
Cain escaped a bases-loaded jam with no outs after Kemp's homer in the fifth. He retired eight straight before giving up another run in the seventh.
Jamey Carroll led off the eighth with a single off Cain, eventually scoring on Uribe's drive into the left-center gap. Loney drove home Uribe with a tying single to right off Wilson, who hadn't pitched in seven days after throwing 10 scoreless innings in his previous 10 appearances.
Wilson tipped over a water cooler in the Giants' dugout after retiring Gibbons to end the eighth.
But Sanchez and Buster Posey singled in the eighth against Cormier, who stayed in the game while closer Vicente Padilla was unavailable with forearm stiffness. After the Dodgers failed to turn a double play, Ross put a high fly into the left-field porch.
Wilson recoiled in pain after throwing to pinch-hitter Russell Mitchell in the ninth, taking a few warmup tosses before deciding to stay in the game.