SAN FRANCISCO -- Pablo Sandoval homered and drove in three runs, rookie Chris Stratton pitched six strong innings and the San Francisco Giants beat the Arizona Diamondbacks 7-2 on Sunday.
The Diamondbacks had won 20 of 25 games and nine straight on the road. Their magic number for clinching a playoff berth was six going into Sunday.
The Giants snapped a four-game skid. Stratton (3-3) struck out four and gave up two runs, five hits and a walk.
Stratton also had the first of three singles leading off San Francisco's three-run fifth. He scored when Austin Slater drew a four-pitch walk off starter Taijuan Walker (9-8).
The Giants loaded the bases with no outs three times - off Walker in the fourth and fifth innings and against T.J. McFarland in the seventh.
Sandoval homered leading off the sixth - his third in 37 games since returning to the Giants in July. He's batting .185 since being acquired.
Sandoval drove in a run in the seventh with a fielder's choice on a fly ball that dropped near left fielder David Peralta, who fired to second get a force out on Brandon Crawford. Sandoval also knocked in the game's first run with a sacrifice fly in the fifth.
J.D. Martinez hit a two-run homer off Stratton in the sixth, his 24th home run in 51 games since the Diamondbacks acquired him in a July trade with the Detroit Tigers.
Walker gave up four runs and seven hits in five innings.
STARTERS' STREAK SNAPPED
Walker's outing snapped a streak of eight straight games in which Diamondbacks starters gave up two or fewer runs. Starters were a combined 5-0 with a 1.62 ERA over that stretch.
Fan favorite Ryan Vogelsong retired as a Giant in a ceremony before the game. Vogelsong was part of the Giants' championship teams in 2012 and 2014.
Giants: C Buster Posey was out of the lineup after fouling a ball off his left big toe Saturday. Manager Bruce Bochy said the injury isn't serious and expects to have him back in the lineup after Monday's day off. ... LHP Will Smith, who had Tommy John surgery in March, started his throwing program on Sunday.
Diamondbacks: LHP Patrick Corbin (14-12, 4.06 ERA) will pitch Monday's series opener in San Diego. Corbin is 6-1 with a 2.12 ERA in his last seven starts. He's 5-6 with a 4.29 ERA in 15 career outings (including 10 starts) against the Padres.
Giants: After the team's day off, Johnny Cueto (7-8, 4.58 ERA) will pitch Tuesday's series opener against Colorado. Cueto is 1-1 with a 4.50 ERA in three starts since coming off the DL with a flexor tendon strain on Sept. 1. He is 9-3 with a 2.66 ERA in in 15 career starts against the Rockies.