Matt Kartozian-USA TODAY Sports

Alek Thomas hit a three-run homer to help the host Arizona Diamondbacks overcome an early four-run deficit and beat the Colorado Rockies 12-5 on Wednesday in the rubber match of a three-game series.

After Colorado took a 4-0 lead in the first, the Diamondbacks (72-68) stormed back, with Thomas' blast capping a five-run rally in the third that put Arizona ahead 6-5.

Thomas added a two-run single an inning later to put the game out of reach. His five RBIs were a career high.

Tommy Pham went 3-for-4 with two doubles, three RBIs and three runs for the Diamondbacks, who pulled within a half-game of the third and final National League wild-card spot.

Arizona's offensive showcase made a winner of Bryce Jarvis (2-0), who tossed two scoreless innings of relief. Rockies starter Chris Flexen (1-7) took the loss.

Nolan Jones had a two-run triple for Colorado (51-88), which has lost 13 of its last 16 games.

Jones' triple and RBI singles from Brendan Rodgers and Hunter Goodman provided Colorado with a 4-0 lead in the first. The Diamondbacks pulled within 4-1 in the home half of the inning thanks to Christian Walker's run-scoring single.

The Rockies added to their lead in the third when Elehuris Montero doubled with one out and later scored on Brenton Doyle's single.

Pham drove in a pair of runs with a double in the bottom of the third before Thomas' go-ahead home run. That duo struck again in the fourth, as Pham walked with the bases loaded and Thomas ripped his two-run single for a 9-5 lead.

Run-scoring singles from Geraldo Perdomo and Lourdes Gurriel Jr. in the fifth and six, respectively, gave the D-backs an 11-5 advantage. Gurriel completed the scoring with a solo shot in the eighth.

Both starters struggled, with neither making it to the fourth inning.

Arizona's Zach Davies allowed five runs on six hits in three innings, while Flexen gave up six runs on four hits in 2 1/3 innings.

Diamondbacks right fielder Corbin Carroll left the game in the fifth with a right wrist contusion after getting hit with a pitch in the fourth.

More must-reads:

TODAY'S BEST
Mavericks provide notable status update on star rookie ahead of Game 5
Watch: Benches clear after Giants buzz Bryce Harper
Wizards make decision on their new head coach
Veteran sportscaster gives valuable insight into Caitlin Clark's WNBA debut
Patriots QB Jacoby Brissett addresses 'elephant in the room'
Iga Swiatek, Naomi Osaka have opposite reactions to crowd following epic French Open match
AEW owner stays quiet on potential interest in top WWE star
Donovan Mitchell's influence on Cavaliers listed among 'most powerful' in the NBA
Clippers 'determined' to keep these two star free agents
AEW sustains another major injury blow after Double or Nothing
Celtics HC Joe Mazzulla offers update on Kristaps Porzingis ahead of NBA Finals
Bengals HC Zac Taylor addresses holdouts from pair of star receivers
Charges against Scottie Scheffler dropped
Yankees icon respects Juan Soto holding out for free agency
Kyrie Irving praises Karl-Anthony Towns for overcoming 'unfair criticism' in Game 4
Cardinals star addresses struggles: 'I don't know what the answers are'
Manchester United star taking break from social media after challenging season
Jets HC explains how former Pro Bowl RB could help team
What Anthony Edwards told Cowboys star after Game 4 win
Bronny James' agent provides huge update on client's future