CHICAGO (AP) — Miles Mikolas outpitched Cole Hamels with eight sparkling innings, and the St. Louis Cardinals stayed alive in the playoff race by topping the Chicago Cubs 2-1 on Saturday.

The Cardinals needed a win plus a loss by Los Angeles at San Francisco to stay in the running for a wild card.

The Cubs, already assured a franchise-record fourth straight trip to the postseason, needed a win plus a loss by second-place Milwaukee to Detroit on Saturday night to clinch their third NL Central title in a row.

gettyimages 1043052308 Mikolas Goes 8 Innings, Cardinals Beat Cubs 2 1

CHICAGO, IL – SEPTEMBER 29: Anthony Rizzo #44 of the Chicago Cubs reaches for a foul ball into the stands hit by Jose Martinez #38 of the St. Louis Cardinals (not pictured) during the eighth inning at Wrigley Field on September 29, 2018 in Chicago, Illinois. The St. Louis Cardinals won 2-1. (Photo by Jon Durr/Getty Images)

Mikolas (18-4) allowed one unearned run and five hits in his fifth straight win. He struck out six, walked none and improved to 10-0 in 16 road starts.

Carlos Martinez worked a perfect ninth for his fifth save in five chances.

Matt Carpenter and Paul DeJong each had RBI singles. Carpenter also scored a run. And the Cardinals got back to winning after matching a season high with four straight losses.

Hamels (4-3) was a tough-luck loser, dropping his third straight start after going 4-0 in his first nine outings following a trade from Texas. The veteran left-hander gave up two runs, one earned, and three hits in seven innings. He struck out eight, walked two and hit two batters.

The Cubs got their run in the first.

gettyimages 1043052730 Mikolas Goes 8 Innings, Cardinals Beat Cubs 2 1

CHICAGO, IL – SEPTEMBER 29: Jesse Chavez #43 of the Chicago Cubs pitches against the St. Louis Cardinals during the ninth inning at Wrigley Field on September 29, 2018 in Chicago, Illinois. The St. Louis Cardinals won 2-1. (Photo by Jon Durr/Getty Images)

Ben Zobrist singled and scored when second baseman Yairo Munoz let Javier Baez’s pop fly deflect off his glove as he tried to make an over-the-shoulder basket catch in shallow right field.

St. Louis scored in the fourth and fifth, with Carpenter playing a role in both runs.

He reached on interference by catcher Victor Caratini and scored on DeJong’s single in the fourth. Harrison Bader got hit by a pitch leading off the fifth and scored on a single by Carpenter, who got thrown out by Caratini trying to take second on the play.

TRAINER’S ROOM

Cardinals: RHP Bud Norris (tight left hamstring) was unavailable, manager Mike Shildt said. Norris faced two batters in the seventh inning Friday before leaving the game.

Cubs: RHP Pedro Strop (strained left hamstring) said he does not expect to pitch again until the playoffs. Injured running to first on a double-play grounder at Washington on Sept. 13, he still experiences some discomfort on the landing throwing off the mound. “I expect to feel it a little bit,” Strop said. “But it was nothing major, nothing like I reinjured it. I knew it was gonna hurt at some point. I’m not afraid of it.”

UP NEXT

Cardinals: RHP Jack Flaherty (8-8, 3.16 ERA) pitches in the regular-season finale on Sunday. He is 0-2 with a 4.50 ERA in his past five starts.

Cubs: LHP Mike Montgomery (5-6, 3.99 ERA) tries to close out the regular season on a winning note after getting tagged for five runs in four innings in a loss to Pittsburgh on Tuesday.

© 2018 by STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.