SAN FRANCISCO -- On a night when Zack Greinke said he didn't have his best stuff the Arizona Diamondbacks ace more than made up for it by hitting his spots.

Greinke pitched eight innings of two-hit ball and Paul Goldschmidt hit a two-run homer as the Arizona Diamondbacks defeated the San Francisco Giants 2-0 on Saturday night.

The Diamondbacks reduced their Magic Number for clinching a playoff berth to six as they won for the 20th time in 25 games and for the ninth straight time on the road.

The Giants have dropped four straight, seven of their last eight and 15 of their last 20. They will need to win at least half of their remaining 12 games to avoid their second 100-loss season in franchise history.

"You don't want to look too far ahead and you don't want to live too much in the past." -- @Dbacks' #MVPaul, whose HR was the difference. pic.twitter.com/KwilO1imvP

FOX Sports Arizona (@FOXSPORTSAZ) September 17, 2017

Greinke (17-6) struck out eight and gave up one walk as he moved into a three-way tie for the major league lead in victories with Clayton Kershaw and Zach Davies.

Asked if he felt the best he has all season, Greinke said "not stuff-wise but location-wise yes.

"Pretty good command, the changeup I haven't had that good command of lately, and the fastball command was better than it's been in the past."

Goldschmidt homered with two outs in the top of the first with David Peralta aboard on a leadoff single. His 34th homer came on the first pitch he saw from Madison Bumgarner (3-9), a 92-mph fastball the Giants ace left over the middle of the plate. Goldschmidt drove the ball well into the bleachers in left center field, a shot estimated at 438 feet by Statcast.

"As good as Madison is, you can't spot him strikes, so I was trying to get something that was in the middle of the plate and try to hit it hard," Goldschmidt said.

Torey Lovullo wanted to drag Zack Greinke off the field after the @Dbacks ace dove headfirst into third base. pic.twitter.com/L6fkFMc0lj

FOX Sports Arizona (@FOXSPORTSAZ) September 17, 2017

Bumgarner struck out six and allowed two runs, seven hits and a walk in seven innings. He lost his fifth straight decision and is winless in last seven starts.

He left the field to a standing ovation.

"This year just hasn't worked out for us and it's frustrating for everybody," Bumgarner said. "The stadium is still pretty full and it's still an awesome place to play."

The Giants got just one man in scoring position, when Mac Williamson went to second on shortstop Kristopher Negron's two-base throwing error.

Greinke was 2 for 3 with two doubles.

Zack Greinke didn't think he was dominant but liked his efficiency in 8 shutout innings in the @Dbacks' 2-0 win over the #SFGiants. pic.twitter.com/IBDAruz2Yz

FOX Sports Arizona (@FOXSPORTSAZ) September 17, 2017

Fernando Rodney pitched a scoreless ninth for his 38th save.

"When Greinke is on and hitting the edges, he's real tough," Giants manager Bruce Bochy said.

TRAINER'S ROOM

Diamondbacks OF J.D. Martinez was back in the lineup after missing Friday's game with neck stiffness. Manager Torey Lovullo said Martinez, one of the hottest hitters in the majors this month, started experiencing discomfort on Wednesday night but played the next day and hit a home run against Colorado. Martinez was 0 for 4 with two strikeouts on Saturday.

Torey Lovullo: #MVPaul's early HR "was the key to the game. … Zack took it over from there." pic.twitter.com/iok5Ak3vpu

FOX Sports Arizona (@FOXSPORTSAZ) September 17, 2017

UP NEXT

Diamondbacks: RHP Taijuan Walker (9-7, 3.32 ERA) will pitch Sunday's series finale. Walker is 3-0 with a 1.54 ERA over his last four starts and is 2-0 with a 0.55 ERA in his last three road starts. He's 3-1 with a 3.26 ERA in five career starts against the Giants.

Giants: RHP Chris Stratton is 2-1 with a 1.96 ERA over his last five starts. He's 0-1 with a 3.27 ERA in two career starts against the Diamondbacks.