How the tables have turned.

Embattled Vermont Sen. Bernie Sanders is treating Michigan’s March 10 primary as a firewall — and possible last stand — to stem the momentum of suddenly surging rival Joe Biden.

Sanders canceled a rally planned for Friday in Mississippi — which also votes next Tuesday — and will instead stump in Michigan, ceding another southern state with a huge black population to Biden, who a week earlier considered South Carolina his “firewall” before a resounding victory propelled him through a near Super Tuesday sweep.

Michigan is the biggest prize of the six states voting on Tuesday, with 125 delegates, followed by the state of Washington (89 delegates), Missouri (68 delegates), Mississippi (36 delegates), Idaho (20 delegates) and North Dakota (14 delegates).

Sanders upset Hillary Clinton in the 2016 primary, but repeating that feat may not be so easy against Biden.

As Barack Obama’s vice president, Biden can claim he helped craft the package that bailed out the state’s reeling auto industry during the last recession. Obama won Michigan in both general elections in 2008 and 2012.

Meanwhile, Biden is dispatching Minnesota Sen. Amy Klobuchar — who dropped out of the race and endorsed him just days ago — to stump for him in Michigan on Friday and Saturday.

And Biden landed the endorsement of Michigan Gov. Gretchen Whitmer, and immediately named her as a national co-chairwoman of his campaign.

But Sanders has strong backing in the Wolverine State as well, including from Michigan’s growing Arab-Muslim population — he landed the endorsement from the Arab American Political Action Committee.

A recent Detroit News-NBC/WDIV TV poll had Biden ahead of Sanders 29 percent to 22.5 percent. The survey was taken from Feb. 28 to March 2 — overlapping Biden’s victory in South Carolina but before his dominant performance on Super Tuesday. Mike Bloomberg, who dropped out of the race, took ten percent in the poll and 16 percent were still undecided.

Sanders will hold a rally in Detroit Friday and in Grand Rapids on Sunday. He is strong in the west, so he is favored to carry Washington, Idaho and North Dakota.

But Missouri, which has a sizable number of black voters in St. Louis, could tip to Biden. Clinton carried Missouri in a squeaker over Sanders in 2016.

The electoral and delegate map going forward appears to favor Biden.

The four states that vote on March 17 include the battleground states of Florida (219 delegates), Illinois (155 delegates), Ohio (136 delegates) and Arizona (67 delegates).

One political expert said he doubted that Sanders could catch Biden in the delegate count – and that was before seeing a new poll in Florida that had Biden ahead of Sanders by nearly 50 points

“Folks…Barring a seismic event, this race is pretty much over,” tweeted Dave Wasserman, US editor of the Cook Report.

Biden leads with 565 delegates to 506 for Sanders. A candidate needs 1,991 delegates to secure the Democratic Party nomination to take on President Trump.