NEW YORK (Reuters) - Federal and state prosecutors said on Thursday they would not bring criminal charges against New York City Mayor Bill de Blasio or his aides in two simultaneous year-long investigations into his fundraising practices.

New York City Mayor Bill de Blasio speaks during a news conference in New York City, U.S., February 28, 2017. REUTERS/Brendan McDermid

But the mayor’s conduct was criticized by prosecutors, with Manhattan District Attorney Cyrus Vance saying de Blasio’s fundraising for other Democratic candidates in 2014 appeared to violate the “intent and spirit” of state campaign finance laws.

The decisions are a victory for de Blasio, who was dogged by questions about the probes as he prepared to run for re-election this year.

It is unusual for prosecutors to announce the conclusion of criminal inquiries. In a statement, Acting U.S. Attorney Joon Kim in Manhattan said it was done “in order not to unduly influence the upcoming campaign and mayoral election.”

At a news conference, de Blasio said the statements confirmed he and his administration had acted lawfully. He dismissed questions pointing out that prosecutors criticized his actions despite deciding not to pursue a case.

“I do not agree with some of the characterizations,” he said. “What matters is the fact that this was extensively investigated for a year, and no charges have been brought.”

U.S. prosecutors had probed whether the de Blasio administration gave favors to donors who contributed either to his campaign or to a nonprofit organization set up to promote his political agenda.

In a statement, Kim said his office had investigated “several circumstances” in which the mayor or his associates contacted or directed agencies on behalf of donors.

The decision not to prosecute, Kim said, was made based on several factors, including “the particular difficulty in proving criminal intent in corruption schemes where there is no evidence of personal profit.”

Vance’s office separately examined whether de Blasio steered campaign contributions to county committees in order to sidestep New York state campaign finance limits.

In a 10-page letter to the state Board of Elections, whose own inquiry led to his investigation, Vance detailed how de Blasio and his allies sought to help Democrats win a majority in the state Senate in 2014.

Wealthy donors were encouraged to give to county committees rather than individual candidates because the limits are much higher for the committees.

The money then flowed from the committees to individual candidates, often within days. While each individual transaction appeared lawful, the overall effect was to evade campaign finance law by creating an “end run” around contribution limits, Vance said.

But Vance said the transfers were approved by an election law attorney working with the coordinated campaign. Under the law, an individual who acts on the advice of an attorney is typically shielded from prosecution.

The conclusion not to bring charges “is not an endorsement of the conduct at issue,” wrote Vance.

Though City Hall was spared, the investigations have previously uncovered multiple unrelated schemes, including some involving high-ranking police officials.

The federal probe was initially centered on two businessmen, Jona Rechnitz and Jeremy Reichberg, who helped raise money for de Blasio in 2013 and 2014.

Reichberg and several police officials were charged in June with a bribery scheme involving prostitutes and luxury trips. Rechnitz had already pleaded guilty in secret and cooperated with investigators.

His assistance also helped prosecutors build a case against the once-powerful head of the city’s correction officers union, Norman Seabrook, who was charged alongside a hedge fund financier with secretly investing union pension funds in exchange for kickbacks.

In yet another fraud linked to the probe, U.S. prosecutors charged two police officers and a Brooklyn man, Alex Lichtenstein, in a bribery scheme involving gun licenses. He was sentenced to more than 2-1/2 years in prison on Thursday after pleading guilty.

Another peripheral figure, restaurateur Hamlet Peralta, was charged last year with running a $12 million Ponzi scheme in a case that grew out of the probe.

Several high-ranking police officials have been disciplined as a result of the investigation into Rechnitz and Reichberg.