ST. LOUIS — Jon Lester gave the Chicago Cubs a much-needed boost.

Anthony Rizzo hit a pair of home runs and Lester pitched eight dominant innings as the Cubs beat the St. Louis Cardinals 7-0 on Wednesday to clinch a playoff berth.

The Cubs improved their major league-best record to 93-52, and their magic number is one to clinch their first NL Central title since 2008. They can wrap up the division crown Thursday night with a win at home over Milwaukee or a St. Louis loss in San Francisco.

Chicago secured at least a wild card because the four-game series between the Cardinals and Giants makes it impossible for both to catch the Cubs in the standings.

“I’ll tell you, if you were in that dugout at the beginning of the game, the guys were dead on their feet,” Chicago manager Joe Maddon said. “To play the kind of game we did today — really hot, last game of a long road trip — I give them a ton of credit. (Lester) really played into all that.”

The Cardinals remained a half-game behind the New York Mets and one game behind the Giants for the two NL wild cards.

Lester (17-4) allowed four baserunners, none of which got past first. Cubs catcher David Ross threw out two Cardinals trying to steal second and Lester faced just two batters over the minimum.

Cardinals outfielder Brandon Moss called Lester one of the best in the game.

“Today was one of those days were he had both working and he wasn’t missing over the middle and he was even throwing some curveballs and change-ups to keep you off of everything,” Moss said.

Lester improved to 7-0 with a 1.02 ERA in his last nine starts. He also helped his cause at the plate with an RBI single in the third.

“I’m just trying to give a good at-bat,” Lester said. “He elevated a changeup for me and I got it far enough out there to give us a run.”

Rizzo’s two-run homer in the ninth gave him 31 homers and 101 RBIs on the season. He is the second Cubs left-handed hitter in franchise history to post multiple 30 home run and 100 RBI seasons (Billy Williams did it in 1965, 1970 and 1972).

“Billy Williams, his numbers speak for himself and he’s done it so many years, so it’s a really good feeling,” Rizzo said.

Ross’ two-run homer in the fifth snapped a 0-for-8 streak and it was his first home run since Aug. 17.

St. Louis starter Carlos Martinez (14-8) gave up four runs and eight hits in six innings.

Martinez started off strong, striking out the side in the first and four of the first six batters he faced. Five of his nine strikeouts came on called third strikes. He entered the game having allowed just 12 homers this season and his home run per nine innings average of 0.63 was second in the National League to the Mets’ Noah Syndergaard (0.52).

Ross’ home run was just third by a right-handed batter against Martinez, who had his four winning decisions streak snapped.

The loss dropped the Cardinals’ home record to 33-41, assuring St. Louis of its first losing record at home since 1999 when it played in Busch Stadium II.

While clinching at least a wild card spot is nice, the Cubs look forward to wrapping up the division at home this weekend, preferably tomorrow.

“Let’s do it,” Maddon said. “The sooner, the better. Then we can make our appropriate plans going forward and really set things up to make our best push.”

TRAINERS ROOM

Cardinals: RHP Michael Wacha (right shoulder inflammation) was activated from the disabled list and will pitch out of the bullpen … OF Matt Holliday (fractured right thumb) is expected to take live batting practice later this week. . RHP Trevor Rosenthal (right shoulder inflammation) could be activated from the DL tomorrow.

UP NEXT

Cubs: LHP Mike Montgomery (1-1, 3.67 ERA) will kick off a four-game series as Chicago hosts Milwaukee on Thursday. The Brewers counter with RHP Jimmy Nelson (14-7, 4.42 ERA)

Cardinals: RHP Adam Wainwright (11-8, 4.45) will look to build on a one run, eight inning performance in his last start as St. Louis travels to San Francisco for a four-game series Thursday. RHP Johnny Cueto (15-5, 2.90) will start for the Giants.