ST. LOUIS — Anthony Rizzo hit a pair of home runs and Jon Lester pitched eight dominant innings as the Chicago 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 lowered their magic number to one for clinching their first NL Central title since 2008. They can do it 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.

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 more than the minimum.

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

DODGERS 2, YANKEES 0

NEW YORK — Los Angeles ace Clayton Kershaw pitched five nearly perfect innings before Justin Turner hit an RBI double off Dellin Betances in a two-run ninth.

The Dodgers took advantage of errors by second baseman Starlin Castro and Betances (3-5) to increase their NL West lead to five games over San Francisco.

The Yankees completed a 7-3 homestand and remained two games behind Toronto for the second AL wild card. Next up, they begin an 11-game trip — their longest of the season — to Boston, Tampa Bay and Toronto.

Kershaw gave up one hit without a walk, pitching through two rain delays in his first career start at Yankee Stadium.

Luis Avilan (2-0) pitched 1 1/3 scoreless innings for the win, and Kenley Janson struck out three in the ninth for his 44th save.

ORIOLES 1, RED SOX 0

BOSTON — Mark Trumbo hit his major league-leading 42nd home run, Kevin Gausman outpitched Rick Porcello over eight innings and Baltimore pulled within a game of AL East-leading Boston.

Baltimore took two of three in the series to pull a game ahead of slumping Toronto for the top AL wild card.

Zach Britton closed for his 43rd save and Baltimore became the first team to beat Porcello at Fenway Park this season.

Gausman (8-10) and Porcello (20-4) had nearly identical line scores over eight innings, each striking out six and allowing just four hits, except Porcello allowed Trumbo’s leadoff shot in the second inning.

Porcello was 13-0 in home starts with one no decision entering the game.

NATIONALS 1, METS 0

WASHINGTON — Tanner Roark pitched seven spotless innings and Wilson Ramos homered in the seventh inning as Washington beat New York.

With one out in the seventh, Ramos hit his 21st home run far over the center-field fence on the first pitch from Fernando Salas (0-1). The Nationals have won five of six.

Roark (15-8) allowed three hits with seven strikeouts and four walks, one intentional.

Blake Treinen pitched the eighth and Mark Melancon got three outs for his 42 save.

TIGERS 9, TWINS 6

DETROIT — Miguel Cabrera’s homer broke a seventh-inning tie, and Detroit rallied for a crucial victory.

The Tigers trailed 5-2 in the fourth inning, but came from behind to pull one game behind Toronto for the second AL wild card.

Ian Kinsler had four hits, falling a homer short of the cycle, and drove in three runs while scoring two. Brian Dozier and Kurt Suzuki homered for the Twins.

Shane Greene (5-4) got the win, while Ryan Pressly (6-7) took the loss after surrendering Cabrera’s homer.

Francisco Rodriguez put up a perfect ninth for his 42nd save.

PADRES 3, GIANTS 1

SAN FRANCISCO — Madison Bumgarner missed a chance at his 100th career win and San Francisco wasted another opportunity for a potential push in the NL West, getting swept by fourth-place San Diego.

Luis Perdomo (8-9) allowed one run in 6 1/3 innings of four-hit ball. Brandon Maurer finished for his 10th save.

Luis Sardinas had an RBI single among his three hits for the Padres.

Bumgarner (14-9) gave up three runs over 6 2/3 innings. The Giants fell five games behind the first-place Dodgers.

RAYS 8, BLUE JAYS 1

TORONTO — Alex Cobb won for the first time in almost two years, and Kevin Kiermaier and Corey Dickerson each hit a two-run homer to lead Tampa Bay past Toronto.

Cobb (1-0) allowed one run and two hits in 6 2/3 innings to win for the first time since Sept. 23, 2014, against Boston. The right-hander recently returned from Tommy John surgery.

Reigning AL MVP Josh Donaldson sat out his third straight game for the Blue Jays and was scheduled to get an MRI on his sore right hip.

Marco Estrada (8-9) yielded four runs in 5 1/3 innings.

ASTROS 8, RANGERS 4

HOUSTON — Jose Altuve and Alex Bregman both left with injuries, but George Springer and Teoscar Hernandez homered, helping Houston keep its fading playoff hopes alive.

Altuve exited after the fourth with right oblique discomfort, and Bregman was pulled in the sixth with right hamstring discomfort.

Houston snapped a three-game losing streak and closed within 3 1/2 games of Toronto for the second AL wild card.

The Astros got just their fourth win in 19 games against the Rangers this season.

Houston’s Joe Musgrove (3-4) allowed three runs and five hits with seven strikeouts in 6 1/3 innings.

Derek Holland (7-8) allowed five runs and seven hits in 5 1/3 innings.

INDIANS 6, WHITE SOX 1

CHICAGO — Josh Tomlin pitched five effective innings in his return to the Indians rotation, Coco Crisp hit a three-run homer in the sixth inning to break the game open and Cleveland beat Chicago to remain six games ahead of Detroit in the AL Central.

Tomlin (12-8) allowed one run and four hits and walked none as he ended a personal five-game losing streak.

Crisp, who also doubled, went deep to left with none out in the sixth to chase Carlos Rodon (7-9), who allowed six runs to match his season high and lost for the first time since July 31.

ATHLETICS 8, ROYALS 0

KANSAS CITY, Mo. — Yonder Alonso and Marcus Semien hit two-run doubles as Oakland beat Kansas City for the third straight game to further ruin the Royals’ postseason chances.

The 2015 World Series champion Royals are five games out in the AL wild card with 17 games left and would have to climb over five teams.

A’s rookie left-hander Sean Manaea (5-9) picked up his first career road victory, retiring 13 of the final 14 batters he faced in five scoreless innings.

Yordano Ventura (10-11) was pulled after 4 1/3 innings.

MARLINS 7, BRAVES 5

ATLANTA — Marcell Ozuna hit a three-run homer and Miami rallied to beat Julio Teheran and Atlanta in a testy game.

The benches for both teams emptied in the seventh inning after Atlanta reliever Jose Ramirez threw inside to Miami ace Jose Fernandez, who had been knocked to the ground by a pitch from Teheran (5-10) in the fifth.

No punches were thrown and Ramirez was ejected.

The comeback from a 4-1 deficit helped Fernandez (15-8) stop a five-game road losing streak, the longest of his career.

PHILLIES 6, PIRATES 2

PHILADELPHIA — Freddy Galvis continued his home run surge, hitting his 19th of the season to lead Philadelphia.

Galvis connected on a two-run shot in the second inning off Steven Brault (0-3) for his 10th homer in the last 32 games.

The Phillies got a rare boost on the mound from righty Jake Thompson (2-5). Thompson, who won for the first time since Aug. 12, allowed six hits and two runs over six solid innings.

Tommy Joseph hit his 19th homer for the Phillies. Jeanmar Gomez got the final two outs of the ninth for his 37th save.

BREWERS 7, REDS 0

CINCINNATI — Junior Guerra pitched six shutout innings, Scooter Gennett and Domingo Santana homered and Milwaukee beat Cincinnati to avoid a three-game sweep.

Guerra (9-3), in his third start since coming off the disabled list with right elbow inflammation, allowed just one baserunner past second base — Jose Peraza on a one-out triple in the third inning.

Tim Adleman (2-4) was the loser.