ST. LOUIS (AP) — Rookie Dylan Carlson homered twice, once from each side of the plate, and the St. Louis Cardinals beat the Milwaukee Brewers 4-3 on Thursday.

Carlson’s homers made a winner out of J.A. Happ, who entered the game 0-3 in his last five starts against the Brewers. Happ (10-8) gave up 3 runs on 9 hits and struck out 7 in 6 1/3 innings, his longest outing since St. Louis acquired him from the Minnesota Twins on July 30.

Kodi Whitley and T.J. McFarland combined for two innings of scoreless relief and Luís Garcia earned his second save as the Cardinals won the rubber game of the series after having their franchise record 17-game winning streak snapped the night before. The streak lifted the Cardinals into next week’s NL wild-card game against the Los Angeles Dodgers or San Francisco.

Carlson, batting from the left side, ambushed a 93-mph pitch from Milwaukee reliever Miguel Sánchez (2-1) into right field for a two-run homer to give the Cardinals a 4-3 lead in the sixth.

It was the second career multi-homer game for the 22-year-old, who also went deep from both sides of the plate against the San Diego Padres on Sept. 17. The Cardinals said Carlson is the first rookie in MLB history to homer from both sides of the plate in the same game multiple times in a single season, citing Elias Sports Bureau.

Brewers starter Brett Anderson gave up two runs in five innings, including a solo home run to Carlson in the third. He retired the last eight batters he faced.

Luis Urías’ opposite-field home run for the Brewers tied the game at 1 in the third.

Milwaukee strung together four straight hits to begin the fourth, capped by RBI singles from Omar Narváez and Keston Hiura to take a 3-2 lead.

POSTSEASON PREP

Cardinals manager Mike Shildt named Adam Wainwright the starter of the wild-card game against either the Dodgers or Giants on Wednesday. Wainwright is 17-7 with a 3.08 ERA this season.

TRAINER’S ROOM

Brewers: INF Rowdy Tellez (right patella strain) is scheduled to play the second of a two-game rehab assignment with Triple-A Nashville on Thursday night and is expected to join the Brewers on Friday in Los Angeles.

Cardinals: C Yadier Molina (right shoulder stiffness) missed his third straight game and INF Edmundo Sosa (right hand) swung the bat and took infield. Both are expected to play this weekend.

UP NEXT

Brewers: LHP Eric Lauer (7-5, 2.93 ERA) will kick off a three-game series at Los Angeles and Clayton Kershaw (10-8, 3.38 ERA) on Friday night. Lauer is 6-0 with a 1.89 ERA in eight career starts against the Dodgers.

Cardinals: RHP Dakota Hudson (1-0, 4.91 ERA) will make his first start in over a year against the visiting Chicago Cubs in the first of three on Friday night. Hudson, who is coming back from Tommy John surgery, made his season debut against the Cubs on Sept. 24, giving up two runs in 3 2/3 innings of relief. The Cubs have not named a starter.