ST. LOUIS (AP)Hanser Alberto hit a tiebreaking single with two outs in the ninth inning and the Los Angeles Dodgers climbed out of a huge hole in a 7-6 victory over the St. Louis Cardinals on Wednesday night.

Los Angeles, which has won eight of nine, charged back from a 6-0 deficit with seven runs over the final three innings. The late rally took unbeaten All-Star Tony Gonsolin off the hook for his first loss of the season after an ineffective start.

Mookie Betts had an RBI double in the eighth and Trea Turner’s two-run single cut it to 6-5. Max Muncy tied it in the ninth with a sacrifice fly.

”We don’t feel like we’re ever out of it, doesn’t matter what the score is,” Muncy said. ”We know who we are. We know what we’ve been doing. You’ve just got to find a way to stay in the game even when it seems like it’s really bad. We’re really good at doing that.”

The Dodgers were shut out on four hits over the first six innings.

”Doesn’t matter how it looks, we just keep on going,” Turner said. ”The way you win is always fun, too. (This) was a little bit more enjoyable in the clubhouse. I just feel like the vibes are up.”

Los Angeles got its NL-leading 26th come-from-behind win. This marked its largest comeback of the year.

”I kind of sound redundant when I say it’s the biggest win of the year,” manager Dave Roberts said. ”But it was a big one.”

Will Smith started the rally with a two-run homer in the seventh. Freddie Freeman went 3 for 3 for the Dodgers and has 12 hits in his last 14 at-bats.

Nolan Arenado hit a two-run homer and Paul Goldschmidt had a two-run single early for St. Louis, which had won three straight.

Alberto, who entered in the eighth, singled to left field off reliever Giovanny Gallegos (2-4) to score Cody Bellinger from third base.

Justin Turner doubled and Bellinger singled to start the ninth.

Craig Kimbrel (3-4) got the win with a scoreless inning of relief. Evan Phillips earned his second major league save and first this season.

The Cardinals got to Gonsolin quickly.

The right-hander, who carried an 11-0 record and a major league-best 1.62 ERA into the game, gave up five earned runs and seven hits over five innings. He had not allowed more than two earned runs in any of his previous 16 starts this season.

”I thought my slider was really bad,” Gonsolin said. ”I didn’t do a good job executing pitches with two strikes. They jumped on some mistakes early.”

Arenado capped a four-run uprising in the third with his 18th homer. Goldschmidt, the previous hitter, broke a scoreless tie with his two-run single.

St. Louis starter Adam Wainwright allowed four hits over 5 1/3 scoreless innings. He struck out five and walked four in a 114-pitch stint. The 40-year-old right-hander, the fourth-oldest player in the majors, has worked five innings or more in 16 of 18 starts this season. He left with a 5-0 lead.

Lars Nootbaar and Andrew Knizner had run-scoring hits for St. Louis.

”To put five on (Gonsolin) was great,” manager Oliver Marmol said. ”You just can’t give up seven from the seventh inning on.”

THE MACHINE ROLLS ON

St. Louis DH/1B Albert Pujols will appear in his fifth All-Star Home Run Derby next Monday in Los Angeles. At age 42, the slugger will become the oldest participant, surpassing Barry Bonds and Rafael Palmeiro, who both competed in 2004 at age 39.

TRAINER’S ROOM

Cardinals: INF Brendan Donovan missed his fifth successive start with a non-COVID-19 illness. He grounded out as a pinch-hitter in the ninth. … OF Tyler O’Neill is likely to return in the next few days. He has been out since June 20 with a knee strain and sore wrist.

UP AND DOWN

The Cardinals activated RHP Drew VerHagen from the 15-day injured list. LHP Matthew Liberatore was optioned to Triple-A Memphis. Liberatore allowed three runs and four hits over 2 1/3 innings of a 7-6 win over the Dodgers on Tuesday.

UP NEXT

Los Angeles LHP Tyler Anderson (9-1, 3.15 ERA) will face RHP Dakota Hudson (6-5, 4.00) in the finale of the three-game series Thursday. Anderson, who has already set a career high for wins, is 0-2 with a 7.90 ERA against St. Louis. Hudson tossed six scoreless innings in a 1-0 loss to Philadelphia on Saturday.

More AP MLB: https://apnews.com/hub/MLB and https://twitter.com/AP-Sports