Mayor Bill de Blasio’s one-time City Hall ally, former Council speaker Melissa Mark-Viverito, is now a surrogate for Hizzoner’s Democratic debate opponent Julian Castro.

Mark-Viverito will spin for Castro, who was former President Barack Obama’s housing secretary, after the second round of debates Wednesday evening, according to his presidential campaign.

The Castro campaign told reporters that Mark-Viverito, who worked alongside de Blasio at City Hall from 2014 through 2017, will be available for telephone and email interviews following the event. The term-limited mayor will share the debate stage with Castro Wednesday night.

Mark-Viverito currently runs Latino Victory, a lefty political action committee.

“Melissa is the acting president of a major Latino organization that’s dedicated to getting Latinos elected up and down the ticket so it makes sense,” said a source close to the former speaker.

“I think Melissa is also very clear-eyed about the mayor’s presidential run and knows like everyone else does he’s not going anywhere,” the source said.

De Blasio failed to reach even the 1% mark in the latest Quinnipiac University poll. Castro, the only Latino in the crowded Democratic field, also failed to register in the July 29 survey. Unlike de Blasio, Castro has met the 130,000 donor threshold to qualify for the third debate in September.

Mark-Viverito was often in lockstep with the mayor during her first couple of years as speaker, and de Blasio never vetoed any Council bills. She later broke from the mayor, pushing him further left on controversial issues like closing the city lockup on Rikers Island and providing free lawyers to undocumented immigrants. The two policies are now focal points of de Blasio’s struggling 2020 platform.

Mark-Viverito also criticized de Blasio during her failed run for public advocate last year.

“During the public advocate’s race she said something like, ‘Yeah, he’s qualified to run. He’s over 35 and alive,'” the source recalled.

Mark-Viverito did not return queries from The Post.

A de Blasio campaign spokeswoman declined to comment.