Updated

Coming off a 7-3 road trip and owning a half-game lead in the NL West had the Los Angeles Dodgers brimming with confidence.

Then the rival Giants came to town.

San Francisco won 8-4 Wednesday night to extend its division lead to 2½ games with its first three-game sweep at Dodger Stadium in five years.

"It was a tough series, and not the way you want to get your homestand going after a great road trip like that," losing pitcher Chris Capuano said. "We came home feeling great, but we're always aware of the potential for a letdown."

The Dodgers have lost seven of 12 games against the Giants, including four of six at home. They got swept for the fifth time this season.

"They outplayed us, they outpitched us, they outhit us," Matt Kemp said. "They did everything they needed to do to win."

Matt Cain pitched seven strong innings and Joaquin Arias homered and drove in a career-high five runs for the Giants, who leave with their largest division lead in a month. The Dodgers last got swept at home by the Giants April 24-26, 2007.

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.

"My first and last innings I made some mistakes in the middle of the plate and those guys made me pay," Capuano said. "We were down three, which is still in the game, so if we could have kept it there, we would have been right in it because we showed some fight late. But when you get down by six or seven runs, it's tough to come back."

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

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. 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.