PHOENIX -- J.D. Martinez has only spent 59 games in the National League, but his manager believes he deserves MVP consideration.
"This guy is unbelievable," said David Peralta, who capped off the rally with a game-ending, bases-loaded walk. "I told him, `Hey, you've got four at-bats without a home run.' Boom! Next at-bat, he hit a home run."
Martinez has 45 homers this season, 29 of them in his 59 games with the Diamondbacks, who acquired him in a trade with the Tigers on July 18. He hit 16 homers in 57 games with Detroit.
His 36 RBI this month set an Arizona record, surpassing Luis Gonzalez' 35 in June 2001.
The major league record for September homers is 17, by Babe Ruth in 1927 and Albert Belle in 1995.
"What can you continue to say about J.D.? He hits his 16th home run and you're talking about historical records now," manager Torey Lovullo said. "He's locked in."
The Diamondbacks began their stirring 2017 season with a come-from-behind, walk-off win over San Francisco. Their final home game of the regular season ended in similar fashion against the same team.
"I guess we started how we finished at home, and these guys did not shut down on a day game after a night game," Lovullo said.
Arizona will be back in action at Chase Field next Wednesday in the NL wild card game.
Daniel Descalso jogged home with the winning run on Peralta's walk for the Diamondbacks' ninth walk-off win of the season.
"The way we came back in this game was unbelievable. We never give up. We always fight anybody," Peralta said. "I was really patient in that at-bat. The pressure is on the pitcher."
After an intentional walk, John Ryan Murphy reached on a fielder's choice to drive in Pollock before Peralta drew the walk.
Denard Span tripled, doubled and scored twice.
Lamb hit his 29th homer of the season in the fifth, a solo shot to right field. Lamb has 103 RBI.
Arizona starter Braden 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.
CAIN CALLS IT A CAREER
San Francisco right-hander Matt Cain said he'll retire after his start at home on Saturday against San Diego.
The 32-year-old Cain informed teammates of his decision in a closed meeting before the game. He pitched the first perfect game in Giants history in 2012.
Cain, 3-11 this season, made his big-league debut with the Giants in 2005. He pitched in two of the Giants' three winning World Series appearances since 2010. The right-hander has a career record of 104-118 with a 3.69 ERA.
The three-time All-Star is nearing the end of his contract with the Giants, who have an option for one more season.
The Giants announced they will honor Cain's career at Sunday's regular season finale, which also falls on Cain's 33rd birthday.
Before the bottom of the first inning, the crowd was informed of Cain's decision in a public address announcement, and Cain doffed his cap to the fans and the Diamondbacks dugout in appreciation of the gesture.
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.
Giants: Mac Williamson was hit in the right hand when he fouled off a pitch in the fourth. He stayed in the game until he was removed for a pinch hitter in the sixth.
Diamondbacks: 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.
More AP baseball: https://apnews.com/tag/MLBbaseball
As spring training begins, we identify baseball's elite, the teams with a chance to compete ... and those who aren't even trying to win this year. Where does your squad land?
Cubs star Anthony Rizzo, a 2007 graduate of Stoneman Douglas High School, was one of about two dozen speakers who addressed a crowd of thousands who came out to show their support at a candlelight vigil for the victims of Wednesday's massacre.
Anthony Rizzo, a native of Parkland, Florida, expresses sympathy for victims of the mass shooting at his high school.
Diamondbacks right-hander Zack Greinke wasn't ready to fully embrace the humidor and its potential effect on Arizona's home games, saying, "I've got to see" whether it'll make Chase Field less hitter-friendly.
Aaron Boone reacts to Justin Verlander's comments that the American League goes through the Astros and how the Yankees will adjust to the pace-of-play changes.
The Red Sox have an agreement to sign free-agent utilityman Eduardo Nunez to a one-year deal with an option for 2019, a source told ESPN. The deal is pending the passage of a physical -- hardly a formality, given the way Nunez finished last season.