Two former New York City police detectives will get five years' probation after they pleaded guilty on misconduct and bribery charges after having sex with a woman in their custody in exchange for her release, prosecutors announced Thursday.

Eddie Martins, 39, and Richard Hall, 34, will be sentenced to probation under a plea deal with Brooklyn District Attorney Eric Gonzalez.

They were accused of raping an 18-year-old woman they arrested for drug possession during a traffic stop in Brooklyn in 2017.

In March, Gonzalez asked a judge to drop the rape, kidnapping, and dozens of other counts and indicted them only on bribery and misconduct charges.

Advocates slammed the decision, but the defense attorney for Hall said he made it clear from the beginning that the former detective accepted a bribe from the woman but did not rape her.

The woman, who goes by the name Anna Chambers on social media, railed against the decision. "F--k the justice system lmfaooo s--ts a joke," she said in a tweet in the afternoon.

Chambers said Hall and Martins detained her after a traffic stop in Gravesend in September 2017 for having marijuana. She said the officers handcuffed her and then brought her to a nearby parking lot, where they allegedly raped her inside their police van. Chambers was 18 at the time.

The DA's office said there is DNA evidence in the case, bodily fluids from the former detectives.

At the time of the arrest, it was not illegal for NYPD officers to have sex with someone in their custody, but state lawmakers have since passed a law prohibiting that in response to the case.

The district attorney's office said it could not move forward with the rape case because of inconsistencies in Chambers's story over the past year. It also said it could apply the new law retroactively.

"These defendants engaged in a shocking abuse of power which they finally acknowledged. While I would have preferred to see them serve prison time, they are no longer members of our police department and with today's plea are convicted felons," Gonzalez said in a statement Thursday announcing the plea deal. "As a result of this disturbing incident, New York passed a law to prohibit police officers from having sex with people in their custody, closing a loophole that had allowed officers to claim the sex was consensual. We could not apply the new law retroactively, and serious credibility issues in this case precluded us from proceeding on additional charges, yet we remained committed to holding these defendants accountable."

Chambers has an ongoing civil lawsuit against the pair, as well as the city and the NYPD.

Martins and Hall both pleaded not guilty to rape charges in October and later resigned from the NYPD.

In a statement Thursday, Police Commission James O'Neill said he would have fired Martins and Hall if they had not quit the department and the case went to a departmental trial.

"When a member of the NYPD is indicted on serious charges like these, it tarnishes all of the admirable things accomplished by other, good officers every day in neighborhoods across New York City. It also stains the legacies of those who paid the ultimate sacrifice in service to New Yorkers," O'Neill said in his statement.