Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — Federal prosecutors Wednesday told a federal judge they will not seek to retry Sen. Robert Menendez on corruption charges, an abrupt turnaround that ends three years of legal trouble for the New Jersey Democrat.

"From the very beginning, I never wavered in my innocence and my belief that justice would prevail," Menendez said in response to the government's move.

Just last week, the Justice Department said it would press to put Menendez on trial again, after the first prosecution ended in a mistrial. But a few days later, the judge handling the case threw out some of the original counts, finding Menendez innocent of charges involving contributions to his campaign.

A Justice Department official said Wednesday that the ruling so weakened the remaining charges that prosecutors determined they did not have a strong enough case to take back to court.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Menendez was accused of illegally accepting favors from a Florida eye doctor, Salomon Melgen, including flights on a private jet to stay at Melgen's resort in the Dominican Republic, three nights at a five-star hotel in Paris, and more than $700,000 in political contributions for Menendez and the Democratic Party.

In return, the government claimed Menendez leaned on federal regulators after Melgen was accused of overbilling Medicare for nearly $9 million. They also claimed he did other favors for Melgen and the eye doctor's girlfriends.

When jurors in November were unable to reach a unanimous verdict, the judge declared a mistrial. Several jurors later told reporters they believed the government's evidence was not convincing.

Related: Feds move to dismiss NJ Sen. Menendez indictment (NBC New York)

The Menendez trial involved the first major federal bribery prosecution since a 2016 U.S. Supreme Court ruling made it more difficult to prove bribery involving public officials.

Menendez, 64, is running for re-election this year to a third term.

"This increases the likelihood of Menendez holding onto his seat in November, especially since he isn't facing a well-known challenger for either the Democratic primary or the general election," said Mark Murray, NBC News senior political editor.

Menendez still faces an investigation by the Senate Ethics Committee. It was suspended when the Justice Department filed its charges, but the process resumed when a mistrial was declared.

"His trial shed light on serious accusations of violating the public's trust as an elected official, as well as potential violations of the Senate’s Code of Conduct," Senate Majority Leader Mitch McConnell, R-Ky., said at the time.