Just a few weeks ago, Joe Biden was calling South Carolina his firewall, the first primary or caucus state where his popularity among black voters could propel his flagging campaign to a victory.

Now he’s hanging on by a thread.

The latest polls of Democrats in the Palmetto State show Biden’s once-commanding 28-point lead in November has shrunken to just five percentage pionts over a now surging Bernie Sanders in the same CBS News/YouGov poll released Saturday.

That result was echoed Monday in an NBC News/Marist poll that also found the two locked in a tight battle — Sanders at 23 percent, closely trailing Biden at 27 percent.

Factoring in the margins of error in each poll, the two are virtually tied, something that seemed unthinkable just weeks ago given the socialist Vermont senator’s lack of support among black voters relative to Biden.

But Sanders is suddenly surging, and setting his sights on a first place finish in South Carolina after a thumping victory in Nevada on Saturday that followed a neck-and neck Iowa caucus finish with former South Bend, Ind. mayor Pete Buttigieg that saw him come in a close second and a resounding win in the New Hampshire primary.

Energized by his victory at the Nevada caucus Saturday, Sanders’ camp is now bullish about toppling Biden in what was once his stronghold state — adding two more rallies in South Carolina before this Saturday’s primary.

Still, after disastrous showings in Iowa and New Hampshire, Biden’s campaign is pinning its hopes on South Carolina’s black Democratic voters to hand him victory and much-needed momentum before Super Tuesday on March 3. A first-place finish by Sanders could be fatal to Biden’s White House bid.

“We’re fighting to win in South Carolina,” top Sanders strategic Jeff Weaver told the New York Times Monday, noting his rise in the polls.

The strength of the far-left party outsider’s run has sent other campaigns scrambling — staffers for Biden, 77, and ex-Big Apple mayor Mike Bloomberg, 78, telling reporters Monday that his nomination would lead to “carnage” for Democrats at the election.

Pressure is also building for candidates polling in the single-digit figures, including Minnesota Sen. Amy Klobuchar, 59, and Buttigieg, 38, to get out of the race or risk handing the 78-year-old Sanders the nomination.

Fourteen states will hold primaries on Super Tuesday when more than a third of national delegates will be awarded.

Polls project Sanders will win the delegate-rich states of California and Texas, giving him a lead that aides in opposing campaigns have warned is “insurmountable.”

In a memo last week, the Bloomberg campaign warned that the bloated field of moderate candidates was splitting the vote and preventing people from coalescing around an anti-Sanders alternative.

“The Nevada results on Saturday really informed a reality that this fragmented field is putting Bernie Sanders on pace to amass an insurmountable delegate lead,” Bloomberg 2020 states director Dan Kanninen told reporters on Monday.

“It’s important for us to understand that if we choose a candidate in this critical election who appeals to a small base like Senator Sanders, it would be a fatal error against a candidate as strong as Donald Trump,” Kanninen continued, noting the strength of Trump’s re-election campaign.

Billionaire Tom Steyer, 62, a fringe candidate who barely rated in the first three states, has also poured millions of dollars from his vast fortune into South Carolina, aggressively courting black voters.

He is polling third in the NBC News/Marist poll with a comfortable lead on Buttigieg, Klobuchar and Massachusetts Sen. Elizabeth Warren.

President Trump’s camp have welcomed a Sanders nomination — claiming Trump would crush the socialist at the November general election.

In a combative email to supporters on Monday, Sanders campaign manager Faiz Shakir claimed everyone opposed to Sanders’ White House bid was in “full panic mode.”

“The establishments — Democratic, financial, media, and Republican — are beyond nervous,” Shakir wrote.

“They’re in full panic mode. They’re realizing they no longer have the power — we do.”