The Brooklyn judge who gave zero jail time to two former NYPD officers — despite their admitting they had sex with a teen in their custody — declared in court that “both sides” had committed crimes.

Prosecutors had asked Brooklyn Supreme Court Justice Danny Chun to send ex-cops Eddie Martins and Richard Hall to the slammer for one to three years.

But the judge said from the bench that while the cops took a bribe — sex from an in-custody suspect, who they then set free — the accuser could also be charged with offering a bribe.

“In this particular case … the other party offering a bribe could also be charged and could also be guilty of offering a bribe or giving a bribe,” Chun said, according to a court transcript.

“Given that there are criminal activities on both sides, however, there is one critical difference here — both the defendants before me are police officers and police officers are sworn to uphold a higher standard of ethical code, behavior or higher standard, period, than other people engaged in criminal activity.”

Chun noted that Martins and Hall were originally hit with 50 counts, including rape and kidnapping, after the 18-year-old woman accused the cops of arresting her on drug possession in Coney Island in 2017, and then assaulting her as she was handcuffed and helpless in their van.

“Every violent felony was dismissed,” he said, referring to prosecutors’ decision, in March, to drop the rape and kidnapping case after uncovering what they called troubling inconsistencies in the testimony of the accuser, who has spoken publicly of the case under the alias of Anna Chambers.

The cops wound up indicted on 11 lesser charges of bribery and official misconduct. Those are the raps they pleaded guilty to on Thursday, and the judge said in turn that he’ll sentence them to just five years probation when they return to court Oct. 10.

“The credibility of the victim, or the complainant, in this case was seriously, seriously questionable, at best,” the judge said Thursday.

He conceded that “there is very, very compelling scientific evidence” behind the prosecution’s case — in which Martins’ semen was recovered from Chambers’ vagina and Hall’s semen from her mouth.

“However, I could also see a possibility that a jury, or a trier of fact, could just come back with convictions just on the misdemeanors” of misconduct, the judge said.

“So, given that possibility and given that both defendants have resigned from the police force and will accept a felony conviction and will accept a sentence of five-year probation, this court felt that it would not be unjust or unfair to offer that sentence without jail time on these pleas,” he said.