Federal prosecutors — including US Labor Secretary Alexander Acosta — broke the law by agreeing to grant serial pedophile Jeffrey Epstein a plea deal and not notify his victims, a judge has ruled.

Acosta, who was an assistant US attorney at the time, acted illegally in 2008 when he failed to tell Epstein’s underage victims that his office was preparing to offer the wealthy pervert a non-prosecution agreement, Florida federal court judge Kenneth Marra wrote in his Thursday opinion.

The federal Crime Victim’s Rights Acts granted Epstein’s more than 30 victims the opportunity to discuss plea negotiations with prosecutors and appear at sentencing.

Instead, the federal case was quietly dropped and sealed, and Epstein quietly pleaded guilty to state court charges in 2008 — serving just 13 months behind bars, per court docs. As part of the plea, victims would not be notified, and the whole arrangement would be kept under seal.

“Particularly problematic was the Government’s decision to conceal the existence of the [agreement] and mislead the victims to believe that federal prosecution was still a possibility,’’ Marra wrote in his Thursday decision. “When the Government gives information to victims, it cannot be misleading. While the Government spent untold hours negotiating the terms and implications of the [agreement] with Epstein’s attorneys, scant information was shared with victims.’’

A spokeswoman for the US Attorney’s Office for the Southern District of Florida did not immediately return a message.

“Epstein used paid employees to find and bring minor girls to him,’’ wrote Marra. “Epstein worked in concert with others to obtain minors not only for his own sexual gratification, but also for the sexual gratification of others.’’

Epstein was released in 2009, and in the decade since has been slapped with numerous lawsuits from his accusers.

Marra’s ruling — which comes after the US Department of Justice kicked off its own investigation into prosecutorial misconduct — does not contain a remedy, but instead advises prosecutors to meet with victims to discuss next steps.

“For more than a decade, the actions of the US Attorney’s Office for the Southern District of Florida in this case have been defended by the Department of Justice in litigation across three administrations and several attorneys general,” a spokeswoman with the US Department of Labor responded when Acosta was asked for comment. “The office’s decisions were approved by departmental leadership and followed departmental procedures. This matter remains in litigation.”

A lawyer for Epstein did not immediately return messages.