The Braves’ losing streak was at three before Sunday, when they trotted out an injury-depleted lineup that featured five backups with combined totals of six home runs and 40 RBIs for their series finale against the Cardinals.

When you least expect it, expect it.

They scored three runs in the first two innings, and Mike Minor pitched seven strong innings in a 5-2 win against the Cardinals at Busch Stadium, where the Braves averted a four-game sweep and reduced their magic number to 20 to clinch the National League East title.

Any combination of Atlanta wins and Washington losses totaling 20 will give the Braves their first division title since 2005.

“You don’t want to get swept, especially by a team that’s probably going to be a playoff team that you have the potential of seeing,” said Braves center fielder Jordan Schafer, who hit a leadoff triple in the first inning and an RBI double in the second, and scored both times. “You don’t want them to have that confidence if you face them in the playoffs. It was a big win for us. We just need to get back to playing good baseball, and we’ll be fine.”

Andrelton Simmons hit his 12th home run for the Braves, who secured the head-to-head tiebreaker against the Cardinals to determine home-field advantage should they finish with the same record and meet in the postseason. They finished 4-3 in their season series against the Cardinals, and already secured tiebreakers against the Dodgers, Pirates and Reds.

Minor (13-5) allowed six hits, one run and one walk in seven innings, and Craig Kimbrel retired the last four batters in order for his 41st save and his first multi-inning save of the season.

“First time we’ve used Kimbrel for a four-out save this year, and that was nice to see,” Braves manager Fredi Gonzalez said. “We may have to do that come postseason, if we’re lucky to get in. He hasn’t pitched in three or four days, and with the off day tomorrow, it was a perfect day to try to do it.”

St. Louis right-hander Lance Lynn (13-8) was charged with nine hits and four runs in seven innings.

The Cardinals scored a run on two hits against Luis Avilan in the eighth inning to pull within 5-2 before Gonzalez brought in Kimbrel to face NL batting leader Yadier Molina with a runner at second. Kimbrel induced a second-pitch groundout and got three outs in the ninth on a pair grounders and a liner to short.

“They let me know beforehand, to be ready for it,” Kimbrel said of the eighth-inning call. “And I was, and was able to go out there and be efficient and not throw too many pitches. That’s kind of nice on a hot day like today.”

Asked if he was ready for multi-inning saves in the postseason, Kimbrel smiled and said, “I’m ready to do that a lot.”

The Braves finished 2-4 on a trip against the Mets and Cardinals, and have a day off Monday before playing Cleveland Tuesday to open a three-game series and nine-game homestand.

At least for one afternoon, concerns about their offense were tempered by a 10-hit performance that was just their second double-digit total in 15 games.

“Quick-strike lineup,” cracked Gonzalez, in his first light-hearted postgame moment in nearly a week, since before Jason Heyward had his jaw broken by a fastball Wednesday at New York. “Quick strike and play defense. That’s the strategy.”

Their reserve-laden lineup produced as many runs in the first two innings Sunday as the Braves totaled in the previous two games.

Schafer tripled and scored on Elliot Johnson’s single in the first inning, and Gerald Laird and Joey Terdoslvich started the second with back-to-back singles. They were driven in by Paul Janish’s one-out single and Schafer’s two-out, ground-rule double for a 3-0 lead.

The Braves tacked on two more on Simmons’ homer in the seventh inning and Gerald Laird’s sacrifice fly in the eighth. Johnson led off the eighth with a single and showed his speed when he stole second and advanced on a wild pitch.

Claimed off waivers Wednesday from Kansas City, Johnson started every game of the series at second base and had four hits and some nice defensive plays.

Pitching on three extra days of rest, Minor gave up two singles to the first three batters of the second inning but didn’t allow more than one base runner in any other inning until the sixth, when Matt Carpenter doubled and scored on a groundout to cut the lead to 3-1.

“At the beginning of the game I didn’t feel that great mechanically,” Minor said. “It was like the third or fourth inning I started feeling like I was pounding the zone, hitting more spots.”