He pushed the limits of the law — but in the end Bill de Blasio won.

The mayor and his aides dodged federal and state charges stemming from their campaign fundraising practices — even though they violated the “intent and spirit” of election law, authorities announced Thursday.

Putting an end to separate, yearlong probes, Acting US Attorney Joon Kim — who took the reins last week when Preet Bharara was fired by President Trump — and Manhattan DA Cy Vance Jr. released coordinated statements saying they were dropping cases against de Blasio and his aides

But even as he announced the end of the criminal probe, Vance offered a harsh rebuke to de Blasio’s fundraising efforts during the 2014 state Senate races, when he skirted around caps on donations to individual candidates by funneling money through Democratic counties.

“This conclusion is not an endorsement of the conduct at issue; indeed, the transactions appear contrary to the intent and spirit of the laws that impose candidate contribution limits,” Vance said.

But because they relied on advice from their election-law attorney, prosecutors couldn’t determine that they “willfully” broke the law.

While the state investigation focused on upstate fundraising, Bharara’s office had been probing whether de Blasio and his aides had been part of pay-to-play schemes, doling out favors in exchange for donations to his 2013 campaign or his now-shuttered non-profit the Campaign for One New York.

That wide-ranging inquiry also delved into the lifting of a city deed restriction on Rivington House, which allowed for the long-protected nursing home to be converted into luxury condos. De Blasio’s dealings with donors who wanted to ban horse carriages were also being probed.

Kim’s statement pointed out that there were “several circumstances” in which de Blasio “made or directed inquiries to relevant City agencies on behalf of” donors seeking official favors from the city.

Regarding his decision not to prosecute, he said it’s difficult to prove “criminal intent in corruption schemes where there is no evidence of personal profit.”

The prosecutors’ decision also clears de Blasio aides Emma Wolfe, the mayor’s director of intergovernmental affairs, and Ross Offinger, the former head of CONY.

They were subpoenaed by the DA’s office and Southern District last year.

At an afternoon press conference, Hizzoner said he was “pleased to see the issue closed” — and “fully expected this conclusion would be reached.”

As for ethical issues raised by the prosecutors’ statements, he simply said: “They have an assessment, I don’t share their assessment.”“Most importantly they confirmed, they made a judgment on whether anything inappropriate happened, and their judgment was it did not,” he added.

Citizens Union Director Dick Dadey said that there are still “serious concerns” about the ethical conduct of de Blasio’s administration.

“While the line was not legally crossed, it was ethically blurred,” he said in a statement.

“It certainly does not serve the public good to create a pay-to-play atmosphere where New Yorkers who have business before the city feel the need to contribute financially to the Mayor’s political and nonprofit interests in order to have their business favorably considered.”



The mayor’s rivals also insisted there’s plenty of slime even if there’s no crime. “The stench of corruption emanating from City Hall remainswith a record number of misconduct investigations into Mayor de Blasio (D-Corruption) at a cost of millions of dollars to taxpayers,” Republican real estate exec Paul Massey, who is running for mayor, said in a mocking email.

But political pundits believe there’s now nothing in the way of de Blasio’s re-election.

“While anything can happen in politics, the people best positioned to succeed in a Democratic primary are now unlikely to run,” said Bradley Tusk, who had been searching for a Democratic challenger for mayor.

“Unless someone unexpected steps up or something unusual happens, we should expect four more years of Bill de Blasio.”

Political consultant George Arzt said de Blasio is now the odds-on favorite, saying, “All his rivals were waiting for something to happen — and nothing happened.”

“At this point, it looks like he has clear sailing toward a second term.”Even Public Advocate Letitia James, who had been mentioned as a challenger, said at City Hall that she’s looking “forward to working with the mayor for the next four years.”

De Blasio is not entirely off the hook, though. The Board of Elections, through its division of election law enforcement, is still empowered to take civil action against the mayor, action which could result in fines and yet another public slap-down.

An Albany insider told The Post that it’s a good bet the BOE attack dogs will now pick up the scent — as Vance seemed to urge.

“This determination does not foreclose the BOE or others from pursuing any civil or regulatory action that they determine might be warranted by these facts,” the DA wrote.

The sprawling federal inquiry came out of a probe into NYPD corruption, which the feds joined in 2014.

Additional reporting by Laura Italiano, Yoav Gonen and Rebecca Rosenberg​