Bill Thompson bailed out of the mayor’s race on Monday, saying he didn’t want to undermine fellow Democrat Bill de Blasio’s chances in the general election.

Thompson’s move was applauded by Gov. Cuomo, who joined a “unity” rally with both candidates outside City Hall.

“It can be much harder to step back than to step forward,” said Cuomo.

“And it takes a man of substance, it takes a man who really believes in public service and believes in the principles of the Democratic Party, to actually do it and that’s what Bill Thompson is doing today.”

The governor concluded: “There is nothing more beautiful than Democratic unity.”

But sources said it was teachers union chief Mike Mulgrew — not Cuomo — who helped persuade Thompson to abandon what could have been a bruising runoff against de Blasio.

“Clearly union leadership loomed large in the Thompson campaign and when they pulled the stopper on the drain, down went the campaign,” said one source.

“I think the message was said very clearly from union leaders across the city that it’s over and you can continue on, but you’ll be standing by yourself.”

The teachers union was Thompson’s most prominent backer and pumped $2.7 million into his campaign.

Thompson emerged from the primary in second place with 26 percent of the vote to de Blasio’s 40.3 percent.

By late Monday, with 90 percent of election machines re-counted, de Blasio was up to 40.6 percent.

A runoff would be held only if de Blasio fell below 40 percent.

Thompson had initially vowed to stay in the race until every vote was counted.

But he changed his tune Monday, noting that he and de Blasio are on the same political wavelength and worrying that it might take days or weeks to count 78,000 paper ballots cast in the race.

“It would be a disservice to my supporters, a disservice to Democrats and most of all, a disservice to the people of New York City, who are desperate for new direction after 12 long years,” Thompson said of extending the process.

“Let me be crystal clear: every single vote should and must be counted. But Bill de Blasio and I want to move our city forward in the same direction.”

Even as he heralded de Blasio’s progressive bona fides, Thompson bashed the city’s Board of Elections for not being able to post final results nearly a week after the polls closed.

“We don’t know how many votes I got or even how many votes were cast,” Thompson complained.

“We’re talking about tens of thousands of votes. That’s a disgrace. In the greatest city in the world, in the greatest democracy on earth, we ought to be able to count all the votes.”

Board of Elections executive director Mike Ryan shot back that he was following the schedule set by law.

“How despicable would we be if we ratcheted up the time frame for the purpose of dealing with political impatience?” Ryan asked.