Chaos reigned Sunday ahead of the Democratic National Convention, as the party’s head was forced to quit, thousands of protesters took to the streets and delegates threatened a walk-out over Hillary Clinton’s vice-presidential pick.

On the eve of the four-day convention to nominate the county’s first female presidential candidate, Democratic National Committee Chairwoman Debbie Wasserman Schultz resigned in disgrace over the hack of emails that showed DNC staffers favoring Clinton over her then rival, Vermont Sen. Bernie Sanders.

Meanwhile, throngs of Sanders supporters marched and pounded on drums, chanting “Hell no, DNC — we won’t vote for Hillary” in the sweltering heat during the first in an expected series of protests in Philadelphia.

A leading Sanders supporter, Norman Solomon, also said a “vast majority” of the socialist’s delegates were considering turning their backs — or even walking out of the Wells Fargo Center — during Virginia Sen. Tim Kaine’s acceptance speech to run as Clinton’s second-in-command.

The ouster of Wasserman Schultz, a Florida congresswoman, came just hours after Democrats revealed that she had been replaced as their convention’s chairwoman by little-known Rep. Marcia Fudge (D-Ohio).

But in a statement announcing she was stepping down as DNC chair effective “at the end of this convention” Wasserman Schultz insisted she would still open and close the convention.

A Democratic source said it would be “very unusual” for anyone other than the convention chair to gavel the political gathering into session.

Wasserman Schultz also said she planned to “address our delegates about the stakes involved in this election not only for Democrats, but for all Americans.”

That claim raised the specter of her getting booed off the stage — like Texas Sen. Ted Cruz was last week when he refused to endorse Republican candidate Donald Trump at the GOP convention in Cleveland.

“There’s no way a speech by Debbie Wasserman Schultz will be well-received by Bernie Sanders delegates,” Solomon, national coordinator of the Bernie Delegates Network, told The Post.

He called Wasserman Schultz’s resignation “long overdue.”

“She should have resigned many months ago. Now the question looms over us here in Philadelphia: Why not immediately? Why wait till the end of the week?” he said.

“There’s no way a speech by Debbie Wasserman Schultz will be well-received by Bernie Sanders delegates.” - Sanders delegate Norman Solomon

University of Virginia political scientist Larry Sabato said that “unless the Clinton campaign has an agreement with the Sanders bunch to let her leave gracefully, it could be a mistake” to let Wasserman Schultz take the podium.

“Of course she’ll be booed, absent an agreement,” Sabato said.

A Democratic insider and Clinton backer with knowledge of the talks that led to the ouster said party officials were working furiously to keep her from making a speech.

“Debbie wouldn’t go,” the source said. “She wouldn’t do it gracefully. She didn’t do it nicely.”

“It won’t be anything like Cruz, though. He was the runner-up for the nomination, and that mattered.”

“The national audience has no clue who [Wasserman Schultz] is, and she’s resigning.”

On Twitter, Trump gloated over the disarray, writing: “I always said that Debbie Wasserman Schultz was overrated. The Dems Convention is cracking up and Bernie is exhausted, no energy left!”

He also heaped praise on Wasserman Schultz’s GOP counterpart, tweeting: “Today proves what I have always known, that @Reince Priebus is the tough one and the smart one, not Debbie Wasserman Shultz (sic).”

Meanwhile, Democratic sources told CNN that the hacked emails had inflamed Sanders supporters and could destroy the party-unity deal between Sanders and Clinton, with one Democrat saying: “It’s gas meets flame.”

And desperate Clinton aides floated a conspiracy theory that Russian hackers had engineered the email scandal in a bid to help elect Trump, who has predicted he’d “get along very well” with Russian President Vladimir Putin.

Clinton campaign manager Robby Mook noted that WikiLeaks released the nearly 20,000 emails right after “changes to the Republican platform to make it more pro-Russian.”

“I don’t think it’s coincidental that these emails were released on the eve of our convention here, and I think that’s disturbing,” Mook told CNN’s “State of the Union.”

Sen. Charles Schumer (D-NY) also said the hack raised “a lot of suspicious and worrisome questions.” Sanders called the emails “outrageous, but not a great shock,” telling CNN that he’d long accused the DNC of trying to undermine him in favor of Clinton.

“Are the Russians trying to influence our election? I don’t have proof of that, but we should be looking into it,” Schumer said during his weekly Sunday news conference.

In a statement, he later said Wasserman Schultz “made the right decision” to quit, adding: “While she deserves thanks for her years of service, the party now needs new leadership that will open the doors of the party and welcome in working people and young people.”

Wasserman Schultz will be replaced as interim party chair by Donna Brazile, an ardent Hillary Clinton supporter who on Sunday said she had apologized to the Sanders campaign over the hacked emails.

“I think, the allegations, the emails, the insensitivity, the stupidity needs to be addressed, and we are going the address it,” Brazile told ABC’s “This Week.”

She is taking a leave from her role as a CNN analyst.

A longtime Democrat strategist, Brazile ran Vice President Al Gore’s disastrous 2000 presidential campaign — which saw him start wearing “reassuring,” earth-toned clothing in a failed bid to win over voters before losing to George W. Bush in an election decided by the US Supreme Court.

Previously, she had to resign from Massachusetts Gov. Michael Dukakis 1988 presidential campaign for publicly alleging that then-Vice President George H.W. Bush had repeatedly cheated on his wife.

Additional reporting by Gina Diadone and Post wire services