DENVER — The home runs are coming in bunches for Mark Trumbo, and the reasons behind the power surge are the least of his concerns.

Trumbo homered in a fourth straight game, matching a career best and an Arizona team record, and the Diamondbacks averted a sweep by beating Colorado 5-3 on Sunday.

“I couldn’t tell you when it’s coming or why it’s happening,” said Trumbo, whose two-run shot in the fifth was the 100th homer of his career. “Maybe the mechanics are just a little more geared to driving the ball right now. It’s not something I’ve consciously thought about too much, but you take what you can get.”

Trumbo’s bat backed the pitching of Wade Miley, who went eight strong innings to extend his mastery over the Rockies.

Miley chipped in at the plate with a career-best three hits, including an RBI single. He also benefited from a defense that turned five double plays as the Diamondbacks won for just the second time in nine games this season.

“Wade did an excellent job and that’s what we needed,” Trumbo said.

Miley improved to 7-0 with a 2.52 ERA in 10 career games (nine starts) against the Rockies, matching the longest winning streak against Colorado to start a career. Three of those wins have come at Coors Field.

“My mentality against these guys is the same as it against anybody else,” Miley said. “They’re very aggressive, and I just try to throw strikes. They’re going to get you sometimes. That’s just how the game works.”

On Sunday, he got them more often than not. The winning pitcher in Arizona’s only other victory this season, Miley (2-1) allowed two runs and seven hits.

D-backs closer Addison Reed gave up a leadoff single to Carlos Gonzalez in the ninth. Gonzalez then stole second and went to third on catcher Miguel Montero’s throwing error. Troy Tulowitzki walked to put runners on the corners.

But Reed induced Wilin Rosario to ground into a run-scoring double play, then got Nolan Arenado to fly out to left for his second save in as many chances.

Trumbo, who walked in his first two plate appearances, connected off Brett Anderson (0-2) for his fifth home run of the season, a two-run shot in the fifth that sailed into the left-field bleachers and stretched Arizona’s lead to 5-0.

Anderson went six innings, allowing five runs and 10 hits.