SAN FRANCISCO (AP) J.D. Martinez slugged yet another home run for the contending Diamondbacks. Otherwise, it was a forgettable day for Arizona.

Pablo Sandoval homered and drove in three runs, rookie Chris Stratton pitched six strong innings and the San Francisco Giants beat the Diamondbacks 7-2 on Sunday.

Arizona had won 20 of 25 games and nine straight on the road. Its magic number for clinching a playoff berth is six.

Martinez hit his 40th home run on a first-pitch fastball Stratton left over the plate, a two-run shot in the sixth inning that halved a 4-0 Giants lead.

It was his 24th home run since joining the Diamondbacks in a midseason trade with the Detroit Tigers. Martinez became just the fifth player in major league history to hit 40 home runs in a season split between two teams.

''I wouldn't say I look early, but I'm always ready to hit. That's how I like to take my at-bats,'' Martinez said.

The Giants snapped a four-game skid. Stratton (3-3) struck out four and gave up two runs, five hits and a walk.

''I'm not sure what happened. It was kind of a dud, I'm not going to lie to you,'' Diamondbacks manager Torey Lovullo said.

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.

''That home run was big,'' Giants manager Bruce Bochy said. ''They were in the ballgame and Pablo gave us a three-run cushion. It's good to see him get around like that. He almost had another one.''

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.

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.

VOGELSONG RETIRES

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.

TRAINER'S ROOM

Giants: C Buster Posey was out of the lineup after fouling a ball off his left big toe Saturday. 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.

UP NEXT

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.

---

More AP baseball coverage: https://apnews.com/tag/MLBbaseball

Copyright 2017 by STATS. Any commercial use or distribution without the express written consent of STATS is strictly prohibited.