Pablo Sandoval hit a splash shot into McCovey Cove, Andres Torres and Buster Posey also homered and the NL West-leading San Francisco Giants beat Arizona 4-1 Thursday, leaving them just one win away from the division title.

San Francisco began the day with a two-game edge over San Diego, which later hosted the Chicago Cubs.

The Giants completed a three-game sweep, won for the eighth time in 10 games and cut their magic number to two. They need to beat visiting San Diego only once in their season-ending, three-game series to claim their first division crown and playoff berth since 2003.

Matt Cain starts Friday night's series opener for San Francisco. It could be to clinch — and it's expected to be an electrifying scene at AT&T Park for all three sold-out games.

Torres' go-ahead, solo homer in the fifth inning helped rookie Madison Bumgarner (7-6) earn his first home victory in eight tries. Posey hit a two-run homer in the sixth, the rookie's seventh shot in September.

Overall, the Giants have hit 16 home runs in their last seven games.

Barry Enright (6-7) lost his fifth straight start. He has given up 12 homers during that span after surrendering just eight longballs in his previous 12 outings.

Sandoval's solo shot into the water beyond right field with two outs in the second prompted one of two kayakers paddling for the ball to jump out of his boat and swim to snag the souvenir.

It was the first home run for the struggling slugger since Aug. 28, a homerless stretch of 66 at-bats. Sandoval has just 12 hits in his last 63 at-bats.

Sandoval connected for his fourth career splash hit and second this year. It was the fifth by a Giant in 2010, 55th by San Francisco overall and 77th total in the 11-year ballpark's history. Barry Bonds, the home run king, has 35 of them.

Arizona loaded the bases against Bumgarner in the fourth, getting Enright's sacrifice fly to tie it at 1. But the D-backs did little else against Bumgarner and the bullpen.

Bumgarner had been 0-3 at home with a 4.95 ERA before winning Thursday. He struck out seven and walked one in five innings, allowing seven hits and one run.

The 21-year-old lefty pitched on an extra day's rest after he had his start pushed back a day as ace Tim Lincecum pitched Wednesday night on normal rest. Bumgarner has allowed only five earned runs in his last 38 innings over his last six starts.

Ramon Ramirez pitched the ninth for his third save in as many tries as the Giants completed their third sweep of the season against Arizona. Manager Bruce Bochy gave All-Star closer Brian Wilson a break after he saved back-to-back games, including a five-out effort Tuesday.

Arizona struck out 12 times after 14 Ks in Wednesday's 3-1 loss. The Giants' pitching staff has a majors-best 1,306 strikeouts and established a San Francisco single-season franchise record, topping last year's total of 1,302.

Notes: Posey also hit seven home runs in July. He'd been in a 1-for-19 stretch before the homer. ... 2B Freddy Sanchez returned to the Giants' starting lineup after missing the first two games of the series with a strained right shoulder. ... Struggling 3B Mark Reynolds was back in the D-backs' starting lineup after missing three straight starts with a sore thumb. He is in an 0-for-19 funk and 3 for his last 34. ... The Giants won the season series 13-5, going 6-2 at home.