PHOENIX -- In a game with a postseason feel between two playoff contenders, Nolan Arenado let his bat do most of the talking.
Arenado circled the bases, celebrated with teammates and exchanged some words with a heckling fan near the visiting dugout.
"There was a guy, he didn't stop talking the whole game. That was a pretty long game," Arenado said. "It is what it is. It was cool, man. It was fine, and he got me fired up, and lucky I was able to tell him to be quiet there for a second."
The Rockies took the first game of a key four-game series between the National League wild-card leader, Arizona, and second-place Colorado. The Rockies moved four games behind the Diamondbacks and 3 1/2 ahead of St. Louis for the second wild card slot.
Arenado drove in four runs with a double and his 33rd home run of the season, and the Rockies won their seventh straight road game and fifth overall.
Left-hander Tyler Anderson, activated from the 60-day disabled list on Sunday, pitched four scoreless innings in relief for the victory. Anderson (4-5) allowed a hit with four strikeouts.
"I thought as he (Anderson) moved into the game, his stuff was better. He started making pitches," Rockies manager Bud Black said. "You could say he was the key to the game."
The Rockies' winning rally started with two outs in the eighth. D.J. LeMahieu tripled over the top of an extreme defensive shift toward right field and Carlos Gonzalez walked against Diamondbacks reliever Jake Barrett (1-1).
Arenado's home run followed, giving him a major-league leading 123 runs batted in on the season. It was his seventh home run to give the Rockies the lead in the eighth inning or later in his career and the third of 2017.
"It was a bad slider. I didn't get exactly on top of the ball," Barrett said.
The Diamondbacks came back with two runs in the bottom of the eighth off Rockies relievers Jake McGee and Pat Neshek. Paul Goldschmidt's ground out drove in Chris Iannetta, and hot-hitting J.D. Martinez singled in A.J. Pollock to cut Colorado's lead to 5-4.
"We pressed them, they pressed us. We came out on top," Black said.
Martinez, on the same day he was named NL Player of the Week for last week when he batted .429 with seven home runs, went 3-for-4 and scored twice.
Holland stranded runners at second and third, inducing a Pollock ground out to end the game.
"We couldn't get that big hit or that big moment to push across for us," Diamondbacks manager Torey Lovullo said. "We had some opportunities. We just didn't do it."
Diamondbacks starter Zack Greinke allowed two runs on five hits with six strikeouts over seven innings.
Greinke, with his fifth-inning strikeout of Anderson, reached 200 strikeouts on the season for the sixth time in his career, all six times since 2009.
Arenado, known for outstanding defense, made the play of the night when he dived to his right to snag a one-hopper headed down the left-field line off the bat of Pollock in the sixth. Arenado sprang to his feet and threw a one-bouncer to first base just in time for the out.
"I was just happy to stop it," Arenado said.
The bat that Martinez used to hit four home runs at Dodger Stadium on Sept. 4 was packed up at Chase Field and sent to the National Baseball Hall of Fame in New York on Monday.
The Rockies' Charlie Blackmon, with his first-inning double, became the sixth leadoff hitter since 1914 to collect 80 or more extra base hits in a season.
Rockies: Starting pitcher Kyle Freeland was struck in shoulder by a line drive off the bat of Martinez in the top of the fourth, and left the game after being checked by a trainer. The Rockies announced later that Freeland had a left shoulder contusion, and Freeland said he also felt the impact on his jaw.
Freeland said he was OK after the game, though he expected soreness.
"Don't throw fastballs down the middle," he said.
Rockies: RHP Jon Gray (7-4) has a 2.55 earned run average over his last seven starts, but he's 1-2 with 5.40 career ERA against Tuesday's foe, Arizona.
Diamondbacks: RHP Taijuan Walker (9-7) faces Colorado with the Diamondbacks having won in each of his past four starts.
Zach Davies failed to hold an early lead and gave up a go-ahead double to Francisco Cervelli in the fourth inning that lifted the Pittsburgh Pirates over the Milwaukee Brewers 3-1 on Saturday night.
Josh Reddick lifts a curveball out to left field to just clear the wall for his 14th home run.
Marwin Gonzalez lines a single over the head of Steven Souza Jr. in right field to plate a pair of runs.
Cesar Hernandez hits a huge 3-run home run to give the Phillies the lead for good in a 5-4 victory.
With the game tied in the eighth, Jake Bauers launches a 3-run dinger to right field.
Alex Gordon hits a pair of 2-run doubles while knocking in five total runs as the Royals top the Twins 10-3.