PHOENIX -- Ildemaro Vargas had a game-tying, pinch-hit homer in the ninth inning on Tuesday and then singled with the bases loaded in the 19th at 1:34 a.m. local time on Wednesday to give the Arizona Diamondbacks a 3-2 win over the St. Louis Cardinals.
Carson Kelly and Nick Ahmed started the final rally with back-to-back singles off John Brebbia (3-4), who was the Cardinals' 11th pitcher of the night. Jarrod Dyson and Robbie Ray -- a pitcher who had to pinch hit -- struck out before Christian Walker was intentionally walked to load the bases.
Then it was Vargas' turn to be the hero again, smacking a single -- his fourth hit of the game -- through the left side of the infield. He raised his hands as players rushed the field to celebrate.
The game lasted 6 hours, 53 minutes and featured 24 pitchers and 48 strikeouts, with both teams plowing through bullpen arms thanks to September's expanded rosters. The Diamondbacks used a franchise-record 30 players. It was the longest game by innings and time in Chase Field history.
The two teams were set to play again in Phoenix 11 hours later.
It's a particularly tough turnaround for the Cardinals, who are locked in a playoff race with the Milwaukee Brewers. St. Louis is 2½ games ahead of Milwaukee in the NL Central. The Cardinals have four games remaining, and the Brewers have five.
The Cardinals' bullpen blew two one-run leads, once in the ninth inning and again in the 13th as they wasted a stellar outing from starter Jack Flaherty.
Paul Goldschmidt looked like he'd be the hero after giving the Cardinals a 2-1 lead in the 13th when he hit a homer for the second straight night in his return to Chase Field. The six-time All-Star spent his first eight seasons with the Diamondbacks before being traded to St. Louis last offseason.
Turns out, there was much more baseball left to play.
Ahmed started the D-backs' 13th-inning rally with a triple, and then Dyson drew a walk off John Gant. Pinch-hitter Caleb Joseph ripped a single through the right side of the infield to tie the score at 2-2, but the rally stalled when Walker hit into a double play and Vargas grounded out.
Several hours before the game's conclusion, Flaherty continued his run of outstanding pitching with seven brilliant innings, including a no-hitter through six, but Andrew Miller couldn't hold a 1-0 lead in the ninth.
With one out, Vargas stunned the Cardinals with a solo shot that just cleared the fence in right-center field and tied the game. Miller retired the next two batters.
The Diamondbacks looked like they might rally in the 11th when Tim Locastro hit a one-out single. With two outs, Vargas hit a high chopper for an infield single, but Locastro was thrown out at third when he barely slid past the bag while trying to take an extra base.
Flaherty, who finished with 11 strikeouts, has been brilliant for the Cardinals as they've charged to the top of the division. The right-hander has a 0.97 ERA during the second half of the season and has given up just seven earned runs over the past two months.
Dexter Fowler provided the Cardinals' early offense, leading off the game with a solo homer to right field. It was Fowler's 18th homer of the season.
Arizona was eliminated from the NL wild-card race after Monday night's 9-7 loss to the Cardinals. Diamondbacks starter Mike Leake gave up one run over six innings and struck out three.
LET'S GET HYPE
By the 15th inning, the D-backs' and Cardinals' benches appeared to be having a good-natured contest to see who could be the most raucous and obnoxious when cheering. It was easily heard because most of the Chase Field crowd was gone.
STARTS WITH A BANG
Fowler had the 26th leadoff homer of his career and second of the season. It came one day after he went 0-for-5 with four strikeouts in the Cardinals' 9-7 win.
Diamondbacks: RHP Merrill Kelly (12-14, 4.31) will head to the mound to begin a game that starts at 12:40 p.m. local time. He'll bring a 15-inning scoreless streak into the game.
Trout on 3rd MVP: 'I always try to be the best player'
Mike Trout joins SVP after winning the American League MVP award and says it was special to be recognized as the league's best player for the third time.
Angels' Mike Trout edges Astros' Alex Bregman for AL MVP
Angels center fielder Mike Trout became just the 11th player with at least three MVP awards when he was named the American League's MVP on Thursday. Trout edged Astros third baseman Alex Bregman for the award.
Cody Bellinger 1st Dodger to win NL MVP since Clayton Kershaw in 2014
Cody Bellinger was named the NL's Most Valuable Player on Thursday, beating out 2018 winner Christian Yelich, who finished second in voting, and third-place Anthony Rendon.
Yankees go high tech, turn to 34-year-old as new pitching coach
Drawn to his high-tech approach, the New York Yankees are turning to unproven 34-year-old Matt Blake as their new pitching coach after losing in the ALCS.
Braves boost shaky bullpen, sign ex-Giants lefty Will Smith
The Braves signed free-agent closer Will Smith to a three-year, $39 million contract on Thursday.
Twins' Jake Odorizzi, White Sox's Jose Abreu accept $17.8M qualifying offers for 2020
Jake Odorizzi, who had a career-high 15 wins and a 3.51 ERA for the Twins last season, and White Sox slugger Jose Abreu, who led the AL with 123 RBIs, have accepted qualifying offers for 2020.