Updated

PHOENIX -- It turns out the Arizona Diamondbacks will have something to play for after all in their final series of the 2015 season.

After rallying for four runs with two outs in the seventh inning to beat the Colorado Rockies 8-4 on Thursday night, the Diamondbacks preserved their chance to finish with a .500 record this season.

However, to do so, Arizona (78-81) would have to sweep Houston this weekend, which could knock the Astros out of their playoff spot. Houston enters the final series of the season with a one-game lead over the Los Angeles Angels and Minnesota Twins for the final AL wild-card spot.

"It'll be fun," Diamondbacks manager Chip Hale said. "It's a chance for us to sort of play our October baseball these three games. So we're going to give it everything we've got. Our bullpen's rested. Our position players know how important this is for us to play at a high level like we've been playing."

Thursday's win finished a three-game series sweep of the Rockies and was Arizona's fifth victory in the last six games.

Welington Castillo had a go-ahead two-run double during the four-run rally with two out in the seventh. Phil Gosselin hit an inside-the-park home run to start Arizona's comeback.

Replays appeared to show Gosselin's drive clearing the yellow line on top of the left-field wall and then bouncing back on the field. Second base umpire Lance Barrett did not indicate a home run and by the time left fielder Rafael Ynoa retrieved the ball and threw it back toward the infield, a hustling Gosselin was headed for home.

"A homer's a homer," Gosselin said. "We wanted to win these last six because .500 is still within reach. We're excited going into the weekend."

Paul Goldschmidt had an infield single and rookie Socrates Brito singled to left before Castillo had his two-run double off reliever Justin Miller (3-3). Castillo then scored on two wild pitches by Boone Logan.

Miller was charged with four runs allowed in 2/3 of an inning.

"Miller has been lights out for us. He has been outstanding," Rockies manager Walt Weiss said. "Those are the first runs he's given up in a while. It was a tough night for him, but he has been really good."

Enrique Burgos (2-2) got the win in relief for the Diamondbacks despite allowing a run on two hits with two wild pitches in the seventh. Silvino Bracho pitched a scoreless ninth for his first major-league save.

Brito, a fourth-inning replacement for injured left fielder David Peralta, went 3 for 3 with two runs scored, a run batted in and a stolen base. Castillo had three RBIs.

"I feel really good here," Brito said of being in the majors. "I don't get nervous."

The Rockies got two doubles and two RBIs from Ynoa and two hits and two runs scored from Kyle Parker.

The Rockies consistently hit the ball hard off Diamondbacks starter Patrick Corbin, with D.J. LeMahieu lining a single off Gosselin's glove to drive in Jose Reyes in the first inning.

The Diamondbacks took a 2-1 lead with two runs in their half of the first off starter David Hale, who pitched five innings. A.J. Pollock came in on a sacrifice fly by Goldschmidt, his 409th career RBI. That passed Chris Young's 408 for sole possession of fourth place on the club's all-time list.

Gosselin scored on Castillo's ground out before the inning was over.

Colorado chased Corbin after back-to-back doubles for Parker and Ynoa made the score 5-4 in the sixth. Corbin was charged with five runs on 10 hits with five strikeouts and a walk in 5 1/3 innings.

Tom Murphy doubled in Nolan Arenado with two outs in the seventh to give the Rockies a 6-4 lead.

THIRD IS THE WORD

The Diamondbacks clinched third place in the NL West behind the division-winning Los Angeles Dodgers and runner-up San Francisco Giants with Thursday's win. Arizona is 78-81 with three games to play and the fourth-place San Diego Padres are 74-85 with three games remaining.

SEE YOU IN APRIL

Arizona and Colorado concluded their 2015 season series Thursday and open up the 2016 regular season in Phoenix with a three-game series April 4-6.

TRAINER'S ROOM

Diamondbacks: Peralta injured his right wrist going for a catch of a sinking line drive in the fourth inning and was removed for a pinch-hitter in the bottom of the inning.

UP NEXT

Rockies: RHP Kyle Kendrick (6-13) makes his final start of the season for the Rockies at San Francisco. He has allowed six earned runs in each of his last two starts, both in Denver. He's 4-7 with a 5.55 ERA on the road this season.

Diamondbacks: Right-hander Rubby De La Rosa is scheduled to open up a three-game series at home against Houston on Friday. De La Rosa is 14-8 with a 4.56 ERA this season. He can become the ninth Diamondbacks pitcher in club history to win 15 games in a season.