Updated

Matt Cain pitched seven strong innings, Joaquin Arias homered and drove in a career-high five runs, and the San Francisco Giants beat the Los Angeles Dodgers 8-4 on Wednesday night to extend their NL West lead to 2½ games with their first three-game sweep at Dodger Stadium in five years.

The Giants arrived in Los Angeles trailing the Dodgers by a half-game and they leave with their largest lead in a month. The Dodgers last got swept at home by the Giants April 24-26, 2007.

The Giants avenged a three-game sweep by the Dodgers in San Francisco last month that created a virtual tie atop the division. Now the Giants are ahead by their biggest margin since a 2 ½-game lead on July 25.

Cain (13-5) allowed one run and seven hits, struck out five and walked none to win his third in a row.

Chris Capuano (11-9) gave up three runs in the first inning before settling down and retiring 13 straight batters. But he became unhinged to start the sixth, giving up three consecutive hits. An RBI single by Pablo Sandoval chased Capuano. The left-hander allowed six runs and six hits in five-plus innings, struck out two and walked none.

Arias hit a two-run homer in the first, giving the Giants a 3-0 lead after Sandoval's sacrifice fly. Those two struck again in the sixth, Sandoval with an RBI single and Arias with a run-scoring double. Shawn Tolleson gave up a bases-loaded walk that scored Sandoval and extended the Giants' lead to 6-0.

The Dodgers' first run came on Hanley Ramirez's RBI single in the sixth.

Arias' two-run RBI double off Jamey Wright in the seventh made it 8-1.

The Dodgers rallied with three runs in the eighth to trail 8-4. Matt Kemp hit a run-scoring ground-rule double against Clay Hensley and Luis Cruz hit a two-run single with the bases loaded off Santiago Casilla before A.J. Ellis hit into an inning-ending double play.

Giants left fielder Justin Christian ran full speed toward the left field corner and robbed Juan Rivera of extra bases with a diving catch on the warning track in the seventh with a runner on first base.

Ethier was 0 for 18 before ending the drought in the sixth with a ground-rule double that was misjudged by right fielder Hunter Pence. It gave Ethier six straight seasons with 30 or more doubles, setting a Dodgers franchise record.

NOTES: Ethier played with a blister on the palm of his right hand. ... Giants C Buster Posey was scratched from the lineup because of tightness in his right hamstring. He's day to day. Posey left after his final at-bat in the seventh inning on Tuesday night after increasing discomfort. ... Giants RHP Brad Penny will join Class-A San Jose on Thursday as he continues his rehab from right shoulder problems, which landed him on the disabled list on Aug. 14. ... Dodgers manager Don Mattingly flip-flopped his starting pitchers for weekend games against the Miami Marlins. LHP Clayton Kershaw will move up a day to start Saturday, while RHP Aaron Harang moves back a day to pitch on Sunday. ... Giants closer Brian Wilson will resume throwing in October as he rehabs from the Tommy John surgery he had on April 19.