The Braves were in danger of being swept by the Marlins in a four-game series for the first time in franchise history. Then they rediscovered the late-inning magic that’s saved them so many times before.

After blowing a ninth-inning lead, the Braves rallied against Dylan Floro in the bottom of the inning, with Dansby Swanson’s walk-off single pushing them past the Marlins 7-6 on Thursday afternoon at Truist Park. It stopped the Braves’ losing streak at four, which equaled their longest skid of the past three seasons.

“That was more like vintage Braves,” Swanson said. “The whole year, it’s felt like things have not gone our direction. So that was more like what we’re all accustomed to. The competitive at-bats in the ninth, the no-quit attitude, the energy, all those things. This is something we can build off of.”

The win ceased one of the more frustrating stretches the Braves have endured in recent years. It also spared them the embarrassment of getting swept by a Marlins team they swept in October in a National League Division Series.

“We hadn’t been playing great. ... Anytime you break a losing streak, it’s good,” manager Brian Snitker said. “To lose two extra-inning games early in the season and come back like we did today, we looked more like ourselves. We had a little life.”

In the first game of this series, the Braves squandered a late lead and lost in extra innings. In the second game, after the Braves tweaked their lineup, the offense performed, but the pitching faltered, with starter Max Fried getting lit up before he injured his hamstring.

The Braves rallied from a 5-0 deficit in the third game, ultimately falling short again in 10 innings. Then came Thursday, when it appeared to be more of the same as starter Ian Anderson and his team fell into a 3-0 hole.

It started with who else but Ronald Acuna, who smashed his MLB-leading seventh homer in the fifth inning, pulling the Braves within one. The shot was his 20th career home run against the Marlins, his most against any opponent. Acuna has scored at least one run in the Braves’ past seven games.

The rally continued in the sixth. Pablo Sandoval entered as a pinch-hitter and did what he’s done three times this season. His three-run homer flipped a 3-2 deficit into a 5-3 lead. Sandoval leads the majors in pinch-hit homers and is one shy of the franchise record for pinch-hit blasts in one season.

Sandoval goes deep: Pinch-hitter Pablo Sandoval hits a three-run homer in the sixth inning of Thursday's Braves-Marlins game. It was Sandoval's third home run in eight at-bats this season - all as a pinch hitter.

Credit: Curtis Compton/ccompton@ajc.com

icon to expand image

Credit: Curtis Compton/ccompton@ajc.com

With Will Smith unavailable after pitching four times in five nights, the Braves turned to lefty A.J. Minter in the ninth with a 5-4 lead. He issued a leadoff walk, and Adam Duvall, a former Brave who haunted them throughout the series, hit a game-tying double. Garrett Cooper’s two-out single put Miami ahead.

Yet the Braves stayed calm. Ender Inciarte and Acuna hit singles against Floro to start the bottom of the ninth. Freddie Freeman drew a 10-pitch walk to load the bases. After Travis d’Arnaud struck out, Ozzie Albies drew a walk that tied the score. That set up Swanson, whose hit ended it.

Since his debut in August 2017, Swanson’s five walk-off hits are tied for the second most in the majors.

“He’s amazing in that situation,” Snitker said of Swanson. “He loves when that pressure is on him. He handles it. He has his whole career.”

During their four-game skid, the Braves were outscored 32-22. Making matters more anger-inducing is the fashion in which they lost. Two of the losses were in extra innings, and the first one included the much-discussed botched replay call Sunday against the Phillies.

That made Thursday’s comeback a bit sweeter. The Braves finally figured it out in the later innings, stopping the bleeding to finish their homestand. And while the difference is only one game, a 5-8 record looks much better than 4-9.

“Keep fighting,” Sandoval said was his recent message to the team. “It’s early in the season. It’s part of our game. You try to win games and sometimes they don’t go your way, but you have to keep everything up and try to do the best we can. That’s the best I can say to my teammates.”

The Braves now embark on a five-game trip. Drew Smyly starts the opener of their three-game series in Chicago on Friday against the Cubs. The Braves also will face the Yankees twice in New York next week.