Image copyright CBS News Image caption Former NYPD officers Eddie Martins (L) and Richard Hall

Two former New York detectives have walked free after admitting to having sex with a handcuffed 18-year-old woman after arresting her.

Eddie Martins and Richard Hall arrested the woman for possession of marijuana before having sex with her in the back of a van in exchange for her release.

They will serve five years probation but escaped the prosecutor's request for one to three years in prison.

The men were initially accused of rape but the charges were later dropped.

On Thursday the former police officers, both in their mid to late thirties, pleaded guilty to official misconduct and other charges linked to the incident.

The police officers pulled the woman over in September 2017 as she was driving with friends and found her to be in possession of marijuana.

They then took turns to have sex with her in the back of the police vehicle, the court heard. The police officers did not report the arrest.

Afterwards, the woman went to hospital, where tests identified DNA matching both detectives.

The rape charges were dropped because the victim's credibility was "seriously, seriously questionable" and the charges could not be proved beyond reasonable doubt, said Justice Danny Chun.

The woman's attorney, Michael N. David, said it was a "complete injustice" that the ex-police officers escaped a jail sentence.

Image copyright Getty Images Image caption This New York police van has the slogan "Courtesy, Professionalism, Respect" painted on the side

As a result of the case, a loophole was closed that previously allowed New York police officers to have sex with those in custody as long as it was consensual.

Martins and Hall, who resigned from the New York police department in 2017, "engaged in a shocking abuse of power", said Brooklyn District Attorney Eric Gonzalez, adding that he "would have preferred to see them serve prison time".

"We could not apply the new law retroactively, and serious credibility issues in this case precluded us from proceeding on additional charges," said Mr Gonzalez, "yet we remained committed to holding these defendants accountable".