ST. LOUIS — Milwaukee’s Ryan Braun fouled off the pitch he liked before coming through for the Brewers.

Braun hit a solo home run in the ninth inning and the Brewers beat St. Louis 2-1 on Sunday, dropping the Cardinals back in the NL wild-card race.

The Cardinals are a half-game behind the Mets for the second wild-card slot.

Braun connected on a 3-2 fastball off Kevin Siegrist (5-3) for his 27th homer of the season and 19th in his career against the Cardinals.

“The 0-1 pitch was the best pitch to hit,” said Braun, who fouled it off. “It was better than the one I hit. The one I hit out was on the black in.”

Milwaukee manager Craig Counsell liked Braun’s approach in the at-bat.

“He hit a couple of foul balls there where he took really good swings,” Counsell said. “He’s (Siegrest) tough on righty’s, always has been. Braun got himself back in the count and he made a mistake. It was a no-doubter.”

St. Louis had tied it in the eighth when Matt Carpenter doubled and scored on Stephen Piscotty’s sacrifice fly off Tyler Thornburg (6-5).

Thornburg struck out three in the ninth.

“We only used Thorny once in the last week so he was well rested,” Counsell said. “We gave him the extra outs. He’s got a great mentality in this role.”

The Cardinals fell to 32-39 at home this season.

“It’s always disappointing,” St. Louis manager Mike Matheny said. “In these close games, you feel like you got a real shot and they’re always hard to swallow when it doesn’t work out.”

The Brewers’ other run came in the first on singles by Scooter Gennett and Braun and a sacrifice fly from Chris Carter.

Milwaukee had just four hits in the game, with Braun getting the only one after the fifth inning.

Zach Davies pitched 7 1-3 innings and gave up one run on five hits while striking out seven and walking one.

“This is a game where you have to battle even harder,” Davies said. “Every pitch counts.”

Cardinals rookie Luke Weaver allowed three hits in six innings. He struck out eight with one walk.

TRAINER’S ROOM

Cardinals: RHP Michael Wacha, who has missed 29 games with shoulder inflammation, is scheduled to throw a bullpen session Monday. He threw one Friday.

ACTIVATED

The Cardinals activated All-Star shortstop Aledmys Diaz from the disabled list. Diaz, 26, had missed 36 games since he broke his right thumb when he was hit by a pitch from the Marlins’ Andrew Cashner. At the time he was injured, Diaz was hitting a team-leading .312 with 14 homers and 57 RBIs in 96 games.

ATTENDANCE

The Cardinals eclipsed the 3 million mark in attendance for the 13th consecutive year and joined the Los Angeles Dodgers as the second team to pass the figure this season. It is the 20th time overall St. Louis has passed the 3 million total.

UP NEXT

Brewers: Wiley Peralta (6-9) will face Cincinnati’s Keyvius Sampson(0-1). Peralta, the opening day starter, earned a win in his last start Sept. 6 in a 12-5 victory over the Cubs.

Cardinals: Mike Leake (9-9) will face Chicago’s Kyle Hendricks (14-7) on Monday night at Busch Stadium. It will be Leake’s 199th career start. He was activated from 15-day DL (shingles) before his last start on Sept. 7 and allowed three runs in 4 1-3 innings for no-decision in a 4-3 loss to Pittsburgh.