PHOENIX -- David Peralta capped a three-run rally in the bottom of the ninth inning by drawing a one-out, bases-loaded walk, giving the Arizona Diamondbacks a 4-3 win over the San Francisco Giants on Wednesday.
J.D. Martinez led off the inning with a solo homer, tying Ralph Kiner's 1949 NL record for home runs in September with 16. Martinez has 45 homers this season, 29 of them with the Diamondbacks, who acquired him in a trade with the Tigers on July 18.
His 36 RBIs this month set an Arizona record, surpassing Luis Gonzalez' 35 in June 2001.
Daniel Descalso jogged home with the winning run in the Diamondbacks' regular-season home finale. Arizona will be back in action at Chase Field next Wednesday in the NL wild card game.
All of the runs were charged to Giants closer Sam Dyson (3-3). J.J. Hoover (3-1) earned the win in relief.
Pablo Sandoval doubled twice and drove in two runs, and Jeff Samardzija threw three-hit ball for six innings for the Giants.
Jake Lamb and A.J. Pollock followed Martinez's homer with singles. Pinch runner Kristopher Negron was thrown out at home by Joe Panik on a fielder's choice by Descalso.
After an intentional walk, John Ryan Murphy reached on a fielder's choice to drive in Pollock, and Peralta drew the walk to end the game.
Denard Span tripled, doubled and scored twice, and Samardzija struck out four with a walk, allowing one run.
Lamb hit his 29th homer of the season in the fifth, a solo shot to right field. Lamb has 103 RBIs.
Span's triple, later followed by Sandoval's first double, opened the game off Diamondbacks starter Braden Shipley. Panik, who'd walked, scored on Brandon Crawford's groundout for a 2-0 lead.
Shipley lasted 3 1/3 innings and allowed three runs on four hits with two strikeouts and two walks.
Murphy, who came into the game in the fifth at catcher, recorded his first hit as a Diamondback with a sixth-inning double.
Diamondbacks relievers Anthony Banda, Jake Barrett, Andrew Chafin and Hoover held the Giants scoreless on two hits over 5 2/3 innings.
SUNDAY RAY DAY
Left-hander Robbie Ray, who started and won Tuesday night's game, will start Sunday in the regular season finale at Kansas City. He is expected to be available if needed in next Wednesday's NL wild card game.
Starters Zack Godley and Patrick Corbin will work out of the bullpen Friday and Saturday. Zack Greinke starts the Kansas City series opener on Friday, followed by Taijuan Walker on Saturday.
Diamondbacks' ace Greinke (17-6) makes his last regular season start Friday against the Royals. It's his final tune-up before the wild-card game, which he is expected to start.