DETROIT, Mich. — Front-running Joe Biden stumbled through his second Democratic primary debate Wednesday night in the face of a withering assault by Sen. Cory Booker, Sen. Kamala Harris and even Mayor Bill de Blasio.

The former vice president was repeatedly caught flat-footed as the trio smelled blood in the water and fought to close the polling gap, hammering Biden in a debate that delivered the fire absent in Tuesday’s installment.

That fire was most often focused on Biden, who was grilled on his Obama-era positions on immigration and health care, as well as his early-career stances on criminal justice and the Iraq War — forcing him into a staggering verbal retreat dotted with aborted trains of thought.

“Anyway…” Biden trailed off multiple times as he struggled to answer attacks and pivot from the defensive.

Even a full-throated Detroit audience vaulted onto the dog pile, with a handful of protesters chanting “Three million deportations!” as Biden fielded a pressing question on the mass Obama-era ouster of illegal immigrants from the US.

“If you cross the border illegally, you should be able to be sent back,” said Biden. “It’s a crime.”

The response invited a cross-Hudson tag team between de Blasio and New Jersey’s Booker.

“No, Mr. Vice President, we’re not going to just let people cross the border,” said Booker, who favors civil penalties, not criminal charges, for illegal immigrants.

Added de Blasio, “Vice President Biden, I didn’t hear your response when the issue came up of all those deportations. … I didn’t hear whether you tried to stop them or not using your power, your influence in the White House.”

Biden side-stepped, floundering to defend President Obama’s record — and his own — by incorrectly stating that Obama signed into law the Deferred Action for Childhood Arrivals policy, which was put into effect through an executive order.

But de Blasio refused to let the issue go, pressing, “You want to be president of the United States. You need to be able to answer the tough questions. I guarantee you if you’re debating Donald Trump he’s not going to let you off the hook.”

To that, Biden pleaded Oval Office confidentiality: “I keep my relationship private. … I expect you would go ahead and say whatever was said privately.”

But Booker smelled blood in the water and delivered one of the night’s most stinging rebukes. “You invoke President Obama more than anybody in this campaign,” lashed Booker. “You can’t do it when it’s convenient and dodge it when it’s not.”

De Blasio hardly escaped the debate unscathed, getting targeted for his handling of the lead contamination crisis in New York’s public housing system, as well as his refusal to ax the NYPD officer involved in the firestorm death of Eric Garner — a point which saw Hizzoner receive his own dose of audience heckling.

But it was the two-term vice president who wore the biggest bull’s-eye throughout the night.

Booker hit home again as Biden frailly tried to insist that there was little difference between their criminal justice platforms, an issue over which the two sparred in the media in the days before the debate.

“If you wan to compare records — and frankly I’m shocked that you do,” offered Booker.

Biden then pivoted 180 degrees, trying to attack Booker’s criminal justice record, including the use of stop-and-frisk while he was mayor of Newark.

“There’s a saying in my community: You’re dipping into the Kool-Aid and you don’t even know the flavor,” came the crowd-pleasing Booker retort.

A frazzled Biden couldn’t even stick the landing in his closing statement, flubbing his call for donations by saying, “Go to Joe 30330 and help me in this fight.”

He presumably meant to say, “Text Joe to 30330,” displayed correctly on his campaign’s Twitter account.

Harris, who shot up the polls after June’s first round of debates in Miami by zeroing Biden in the crosshairs, tried to double down the strategy.

But she couldn’t lean in quite as hard, forced to fend off some heat of her own, particularly on her have-it-all-ways health care plan and record as a prosecutor.

New York Sen. Kirsten Gillibrand and former Housing and Urban Development Secretary Julián Castro got in some licks of their own on women’s issues and immigration, respectively.

The remainder of the 10 White House hopefuls generally took a less aggressive approach and consequently found themselves buried amid the fireworks that resulted from a seemingly looser CNN production than the one that dammed the flow on Tuesday night.

They include: Washington Gov. Jay Inslee, Colorado Sen. Michael Bennet, Hawaii Rep. Tulsi Gabbard and outsider businessman Andrew Yang.

Though the first votes for the Democratic primary are more than a half-year down the road, the second round of nationally televised debates carried a sense of particular urgency for the back-of-the-pack candidates.

More than a dozen of the hopefuls are currently on the outside looking in of the Democratic National Committee’s newly implemented polling and fundraising thresholds for invites to September’s third round of debates in Houston.