PHOENIX -- Carlos Gonzalez, heating up for the stretch run after a subpar season at the plate, homered twice and the Colorado Rockies won their sixth game in a row, beating the Arizona Diamondbacks 4-2 on Tuesday night to tighten the race for the National League's top wild card.
Gonzalez drove in all four Colorado runs in his first multihomer game since Aug. 16 last year and is batting .451 (14 for 31) in September.
Jon Gray (8-4) gave up two runs and scattered seven hits over seven solid innings, striking out 10 with no walks and a hit batter for the Rockies, who won their eighth straight road game to pull within three games of Arizona for the first NL wild card.
Gray matched the season high for strikeouts he set in a win at Arizona on June 30. Chris Rusin got two outs for his second save.
J.D. Martinez homered for the 22nd time in 47 games with the Diamondbacks and just missed another with a double off the top of the right-field fence leading off the ninth. He was stranded at third when Ketel Marte grounded out to end the game.
Martinez's 38 home runs overall this season tied his career high.
Gonzalez's two homers -- one off starter Taijuan Walker, the other off reliever David Hernandez -- hit almost the same spot off the wall above the swimming pool in right field. Hernandez (2-1) pitched two-thirds of an inning and took the loss.
The Diamondbacks have lost two straight to Colorado halfway through a four-game series and have dropped four of their last five, all at home, after a 13-game winning streak. The Rockies' eight-game road winning streak matches their second-longest in club history.
The game was tied at 2 through six and lefty Andrew Chafin got Charlie Blackmon to fly out to start the seventh. Hernandez came on and DJ LeMahieubeat the extreme shift Arizona puts on against him with a rare single to left.
Gonzalez followed with his second two-run homer and Colorado led 4-2.
Arizona scored first when Martinez hit Gray's pitch off the edge of the batter's eye, an estimated 447 feet, leading off the second.
The Rockies countered in the third when Blackmon drew a leadoff walk from Walker, and Gonzalez sent Walker's 1-0 pitch to right.