Matt Carpenter homered in the 10th inning against Craig Kimbrel in the All-Star closer's return, and the St. Louis Cardinals regrouped after blowing a late lead to beat the Chicago Cubs 5-4 Thursday night.

Emerging ace Jack Flaherty shut down Chicago over eight innings, and despite a tying three-run rally in the ninth, the Cubs dropped a game behind Milwaukee for the second NL wild card and four games behind St. Louis for first place in the NL Central.

More Images
St. Louis Cardinals' Matt Carpenter, center, celebrates in the dugout with relief pitcher Carlos Martinez, right, after he hit a home run against the Chicago Cubs during the tenth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Matt Carpenter homered in the 10th inning against Craig Kimbrel in the All-Star closer's return, and the St. Louis Cardinals regrouped after blowing a late lead to beat the Chicago Cubs 5-4 Thursday night.

St. Louis Cardinals starting pitcher Jack Flaherty delivers during the first inning of a baseball game against Chicago Cubs the Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Carpenter homered to deep center field off Kimbrel (0-3), who was activated from the injured list prior to the game after dealing with right elbow inflammation. Carpenter, diminished to a smaller role during a frustrating season, hadn't homered since Aug. 25.

Chicago Cubs relief pitcher Craig Kimberly delivers during the tenth inning of a baseball game against the St. Louis Cardinals, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs relief pitcher Craig Kimberly delivers during the tenth inning of a baseball game against the St. Louis Cardinals, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader, third from right, reacts after hitting an RBI-double as Chicago Cubs second baseman Ben Zobrist, second from right, looks on during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader, third from right, reacts after hitting an RBI-double as Chicago Cubs second baseman Ben Zobrist, second from right, looks on during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Paul Goldschmidt scores during the sixth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Paul Goldschmidt scores during the sixth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs left fielder Kyle Schwarber makes a fielding error on an RBI-single hit by St. Louis Cardinals' Yadier Molina during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs left fielder Kyle Schwarber makes a fielding error on an RBI-single hit by St. Louis Cardinals' Yadier Molina during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader hits an RBI-single during the fifth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader hits an RBI-single during the fifth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs' Anthony Rizzo (44) celebrates with Nicholas Castellanos, left, after Rizzo hit a home run against the St. Louis Cardinals during the third inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs' Anthony Rizzo (44) celebrates with Nicholas Castellanos, left, after Rizzo hit a home run against the St. Louis Cardinals during the third inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Cubs slugger Anthony Rizzo provided a jolt in his unexpected return from a sprained right ankle, homering in the third inning to tie the game at 1. But Flaherty was spectacular otherwise, pitching three-hit ball while allowing just the one run and striking out eight.

St. Louis Cardinals' Matt Carpenter, center, celebrates in the dugout with relief pitcher Carlos Martinez, right, after he hit a home run against the Chicago Cubs during the tenth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Matt Carpenter, center, celebrates in the dugout with relief pitcher Carlos Martinez, right, after he hit a home run against the Chicago Cubs during the tenth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Carpenter homered to deep center field off Kimbrel (0-3), who was activated from the injured list prior to the game after dealing with right elbow inflammation. Carpenter, diminished to a smaller role during a frustrating season, hadn't homered since Aug. 25.

Giovanny Gallegos pitched a perfect 10th for his first save in two chances. Andrew Miller (5-5) recorded the final two outs in the ninth for the victory.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports

St. Louis Cardinals starting pitcher Jack Flaherty delivers during the first inning of a baseball game against Chicago Cubs the Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals starting pitcher Jack Flaherty delivers during the first inning of a baseball game against Chicago Cubs the Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs relief pitcher Craig Kimberly delivers during the tenth inning of a baseball game against the St. Louis Cardinals, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs relief pitcher Craig Kimberly delivers during the tenth inning of a baseball game against the St. Louis Cardinals, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader, third from right, reacts after hitting an RBI-double as Chicago Cubs second baseman Ben Zobrist, second from right, looks on during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader, third from right, reacts after hitting an RBI-double as Chicago Cubs second baseman Ben Zobrist, second from right, looks on during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Paul Goldschmidt scores during the sixth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Paul Goldschmidt scores during the sixth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs left fielder Kyle Schwarber makes a fielding error on an RBI-single hit by St. Louis Cardinals' Yadier Molina during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs left fielder Kyle Schwarber makes a fielding error on an RBI-single hit by St. Louis Cardinals' Yadier Molina during the sixth inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader hits an RBI-single during the fifth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

St. Louis Cardinals' Harrison Bader hits an RBI-single during the fifth inning of a baseball game against the Chicago Cubs, Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs' Anthony Rizzo (44) celebrates with Nicholas Castellanos, left, after Rizzo hit a home run against the St. Louis Cardinals during the third inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)

Chicago Cubs' Anthony Rizzo (44) celebrates with Nicholas Castellanos, left, after Rizzo hit a home run against the St. Louis Cardinals during the third inning of a baseball game Thursday, Sept. 19, 2019, in Chicago. (AP PhotoMatt Marton)