Rookie pitcher Josh Fleming allowed four hits over six innings and the AL East champion Tampa Bay Rays eliminated the Philadelphia Phillies from the playoff race with a 5-0 victory Sunday.

Philadelphia needed a win over the Rays and losses by San Francisco and Milwaukee to earn its first playoff berth in nine years. The Brewers and Giants both lost, but the Phillies were unable to give themselves a chance.

The Phillies, who were swept by the Rays in the three-game series and lost seven of eight overall to finish the season, went 28-32 under first-year manager Joe Girardi. They went 81-81 in 2019 with Gabe Kapler at the helm.

Philadelphia Phillies' Bryce Harper reacts after grounding out against the Tampa Bay Rays during the eighth inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Philadelphia Phillies' Bryce Harper reacts after grounding out against the Tampa Bay Rays during the eighth inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Fleming (5-0) struck out five and walked one for the top-seeded Rays, who will face No. 8 seed Toronto in a best-of-three wild-card series that starts Tuesday at Tropicana Field.

Oliver Drake, Aaron Loup and Ryan Sherriff completed a six-hitter.

Tampa Bay (40-20) has the AL’s top record after reaching the postseason last season as a wild card.

Tampa Bay Rays second baseman Michael Brosseau, top, throws over Philadelphia Phillies' Roman Quinn to complete a double play against batter Andrew McCucthen during the third inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Tampa Bay Rays second baseman Michael Brosseau, top, throws over Philadelphia Phillies' Roman Quinn to complete a double play against batter Andrew McCucthen during the third inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Pinch-hitter Kevan Smith had a run-scoring single in the second before Joey Wendle and Hunter Renfroe both had third-inning RBI hits off Aaron Nola (5-5) that put the Rays up 3-0.

Nola gave up three runs and six hits in 3 2/3 innings.

Mike Brosseau hit an RBI triple that bounced over right fielder Phil Gosselin’s head and scored on Héctor Neris’ wild pitch when Michael Perez struck out to make it 5-0 in the sixth.

Philadelphia Phillies starting pitcher Aaron Nola throws against the Tampa Bay Rays during the first inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Philadelphia Phillies starting pitcher Aaron Nola throws against the Tampa Bay Rays during the first inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Philadelphia loaded the bases with two outs in fourth but Fleming got a grounder from Gosselin.

Phillies rookie Alec Bohm doubled in the eighth and had a hit in 18 of his last 20 games.

MAJOR CONFIDENCE

It was not known before the game if the Rays would play the New York Yankees or Toronto in the first-round series.

Tampa Bay Rays' Hunter Renfroe follows through on an RBI-single against the Philadelphia Phillies during the third inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

Tampa Bay Rays' Hunter Renfroe follows through on an RBI-single against the Philadelphia Phillies during the third inning of a baseball game Sunday, Sept. 27, 2020, in St. Petersburg, Fla. (AP PhotoMike Carlson)

But Tampa Bay hitting coach Chad Mottola said pregame that he felt both teams would prefer not taking on the Rays.

“I know no one wants to play us,” Mottola said. “I would think they’re going to play today, both teams, knowing that they want to avoid us.”

TRAINER’S ROOM

Rays: Smith hit for CF Brett Phillips, who left with right hamstring tightness. ... Manager Kevin Cash said OF Austin Meadows (left oblique strain) is “not close” to returning. ... LHP José Alvarado (left shoulder inflammation), 1B Ji-Man Choi (left hamstring strain) and INF Yandy Díaz (right hamstring strain) will take part in a simulated game Monday. ... OF Manuel Margot (sore foot) was scratched from the lineup.

UP NEXT

Phillies: Will host Toronto in Clearwater, Florida, to begin 2021 spring training on Feb. 27.

Rays: The first-round rotation will be LHP Blake Snell (4-2), RHP Tyler Glasnow (5-1) and RHP Charlie Morton (2-2).

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