Federal prosecutors in Florida violated the rights of victims by secretly reaching a non-prosecution agreement with a wealthy financier accused of sexually abusing dozens of underage girls, a federal judge ruled Thursday.

U.S. District Judge Kenneth Marra said in a 33-page decision that victims of financier Jeffrey Epstein should have been consulted under federal law about the deal. Marra stopped short of invalidating the non-prosecution agreement but asked prosecutors and victims' lawyers to recommend in 15 days how to move forward.

"While the government spent untold hours negotiating the terms and implications of the (agreement) with Epstein's attorneys, scant information was shared with victims," Marra wrote. "Instead, the victims were told to be 'patient' while the investigation proceeded."

The law, Marra added, "lends itself to only one interpretation; namely, that victims should be notified of significant events resulting in resolution of their case without a trial."

Epstein, now 66, reached the deal in 2008 with then-Miami U.S. Attorney Alexander Acosta's office to end the federal probe that could have landed him in prison for life. Epstein instead pleaded guilty to lesser state charges, spent 13 months in jail, paid financial settlements to victims and is a registered sex offender.

Acosta, now President Donald Trump's labor secretary, has defended the deal as appropriate given what prosecutors knew and could prove at the time, especially with many victims reluctant to testify. Marra said in his ruling he was not passing judgment on whether the deal should have been struck, only that victims' rights were violated.

Bradley Edwards, attorney for two victims who brought the lawsuit, said the decision should mean the non-prosecution agreement is thrown out — possibly exposing Epstein to federal charges once again. The agreement also granted immunity to anyone who assisted Epstein in finding the underage girls or concealing the abuse.

"Rather than work to correct the injustices done to the victims, the government spent 10 years defending its own improper conduct," Edwards said in an email. "It is time for the government to work with the victims, and not against them, to hold everyone who committed these crimes accountable."

The Miami U.S. attorney's office declined comment Thursday. The Justice Department, however, recently opened a separate investigation into the handling of the Epstein case to determine whether prosecutors committed professional misconduct.

Earlier this month, the Labor Department run by Acosta issued a statement saying the secretary welcomes the Justice Department probe.

"For more than a decade, this prosecution has been reviewed in great detail by newspaper articles, television reports, books, and congressional testimony," the statement said, adding that "the actions taken were in accordance with department practices, procedures, and the law."

Court documents show Epstein had a Palm Beach, Florida, mansion where at least 40 underage girls were brought for what turned into sexual encounters. Authorities say he had female fixers who would look for suitable girls, some local and others recruited from Eastern Europe and other parts of the world.

Before the scandal broke, Epstein was friends with Trump and had visited his Mar-a-Lago resort. Trump at the time told interviewers that Epstein was "a great guy." Records also show former President Bill Clinton flew on Epstein's jet more than two dozen times on various philanthropic trips. Neither Trump nor Clinton have been implicated in any wrongdoing.

Epstein also has a home in New York City, a ranch in New Mexico and a private Caribbean island.