Pinch-hitter Corbin Carroll's two-run triple capped a three-run rally in the eighth inning and the Arizona Diamondbacks beat the St. Louis Cardinals 3-1 on Tuesday night to snap a five-game losing streak.

Arizona rallied late to win for just the third time in 11 games since the All-Star break.

Trailing 1-0, Arizona tied it in the eighth off JoJo Romero (2-1), who had retired the side in order in the seventh in relief of Steven Matz. Ketel Marte led off with a triple to the gap in left-center and scored when Jake McCarthy punched a single up the middle through St. Louis’ drawn-in infield.

CLICK HERE FOR MORE SPORTS COVERAGE ON foxnews.1eye.us

Corbin Carroll reacts

Corbin Carroll #7 of the Arizona Diamondbacks reacts after hitting a two-RBI triple against the St. Louis Cardinals during the eighth inning of the MLB game at Chase Field on July 25, 2023 in Phoenix, Arizona.  (Christian Petersen/Getty Images)

Chris Stratton relieved and retired two batters but walked pinch-hitter Dominic Canzone before Carroll, batting for Emmanuel Rivera, drove one to the center-field wall, where Dylan Carlson could not make the play.

"I think that one meant a little more," said Carroll, who was getting a day off until the eighth. "We got a lot of guys that are grinding right now. Just to put one in the win column takes some pressure off."

Kyle Nelson (5-2) got one out in the eighth inning. Kevin Ginkel pitched the ninth for his third save.

Merrill Kelly returned from the injured list for Arizona and went six innings, giving up just one run on four hits. The right-hander, who threw 86 pitches, last appeared in a game June 24 before being sidelined with right calf inflammation.

"It was good to be back. I got a little tired towards the end, but I feel good," Kelly said. "It felt super muggy, I was sweating like crazy."

But he made sure the game stayed close until the Diamondbacks could win it at the end.

DESANTIS NEEDLES MLB FOR REMOVING 2021 ALL-STAR GAME FROM ATLANTA DUE TO OUTCRY OVER GEORGIA'S VOTING LAWS

Merrill Kelly throws pitch

Starting pitcher Merrill Kelly #29 of the Arizona Diamondbacks pitches against the St. Louis Cardinals during the second inning of the MLB game against the St. Louis Cardinals at Chase Field on July 25, 2023 in Phoenix, Arizona. The Diamondbacks defeated the Cardinals 3-1.  (Christian Petersen/Getty Images)

"We were kind of flat," Diamondbacks manager Torey Lovullo said. "Merrill kept us in the game, it was great to have him back. And what can you say about Corbin? It's probably one of the few pinch-hit opportunities he's had, gets a ball he's looking for and drives it off the center-field wall. Dom's at-bat that handed it off to Corbin ... a very well-timed win."

Matz pitched six shutout innings for his longest outing of the season. The left-hander gave up five hits, walked one and struck out six.

"He did a really nice job," Cardinals manager Oliver Marmol said. "Changeup was good, fastball got away from him at times, but he was aggressive. He gave us a shot."

Matz's only win of the season was in his previous start against the Cubs in Chicago, but Marmol is encouraged by consecutive strong outings.

"We're seeing a guy who's pitching with more confidence, there's intent behind what he's doing and he's aggressive. I think his stuff has always played, now it's a matter of having conviction behind it," Marmol said.

ASTROS BEAT RANGERS IN AL WEST SHOWDOWN BEHIND JP FRANCE'S STRONG OUTING

Ketel Marte reacts after hitting triple

Ketel Marte #4 of the Arizona Diamondbacks reacts after hitting a triple against the St. Louis Cardinals during the eighth inning of the MLB game at Chase Field on July 25, 2023 in Phoenix, Arizona. The Diamondbacks defeated the Cardinals 3-1.  (Christian Petersen/Getty Images)

The Cardinals’ run scored on a double steal in the third. Brendan Donovan doubled past the first-base bag with one out and moved to third on Paul Goldschmidt’s bloop single to right. With a full count on Nolan Arenado, Goldschmidt took off for second. Arenado struck out and catcher Carson Kelly threw to second, while Donovan ran home and beat the return throw.

To make room for Kelly, the Diamondbacks designated right-hander José Ruiz for assignment.

WEB GEMS

Lourdes Gurriel Jr. made two fine catches in left field for Arizona. He went back to the warning track in left field to take an extra-base hit away from Donovan leading off the game, and with a runner on second for St. Louis and two outs in the sixth, Gurriel ventured all the way over to the 413-foot sign in left-center to haul in Tyler O’Neill’s drive.

GOOD WORK

Cardinals RHP Adam Wainwright was honored by the Diamondbacks before the game. The 18-year veteran, retiring after the season, was presented with a $5,000 donation to his foundation, Big League Impact, which provides clean water, education and other amenities to communities.

CLICK HERE TO GET THE FOX NEWS APP

Kevin Ginkel celebrates

Relief pitcher Kevin Ginkel #37 of the Arizona Diamondbacks celebrates after defeating the St. Louis Cardinals 3-1 in the MLB game at Chase Field on July 25, 2023 in Phoenix, Arizona.  (Christian Petersen/Getty Images)

NEXT

Jack Flaherty (7-6, 4.39) starts for St. Louis against fellow RHP Zac Gallen (11-4, 3.18) in Wednesday’s series finale.