NEW YORK — A judge says he's choosing probation over jail for two ex-New York City detectives accused of having sex in a police van with an 18-year-old woman they had arrested for marijuana possession.

Eddie Martins, 39, and Richard Hall, 34, pleaded guilty Thursday to official misconduct and other charges stemming from the September 2017 encounter.

Judge Danny Chun said he'll sentence the men in October to five years of probation. Prosecutors wanted them jailed for at least a year. Sentencing is set for Oct. 10.

Former New York detectives Richard Hall and Edward Martins. NBCNY

"These defendants engaged in a shocking abuse of power which they finally acknowledged," said Brooklyn District Attorney Eric Gonzalez. "While I would have preferred to see them serve prison time, they are no longer members of our police department and with (their) pleas are convicted felons."

The Brooklyn district attorney's office had dropped kidnapping and rape charges against Martins and Hall in March, citing "serious credibility issues."

The case spurred legislation to close what some called a police sex loophole. While New York law already bars sex between prison guards and inmates, it didn't apply to officers and those in their custody. The loophole has since been closed.

The victim was driving with two friends near Coney Island when the two plainclothes detectives pulled her over and found marijuana. After they released her, the woman went to the hospital, where prosecutors say DNA was obtained that matched both men. The officers, who resigned after the allegations broke, pleaded not guilty and claimed the sex was consensual.

"This case was botched from day one," Martins' lawyer, Mark Bederow, told the New York Post. "They never should have allowed these men to be smeared as rapists and whatnot."