Mr. Hall’s lawyer, Peter Guadagnino, said the detectives were dedicated to being police officers, even though they quit in the uproar that followed the September 2017 allegations. “They still feel hurt,” he said.

The case against the detectives began to fall apart in recent months after defense lawyers highlighted evidence from security cameras and cellphones that contradicted the woman’s statements about what she wore that night, what the inside of the van looked like and where the men drove her.

In January, prosecutors acknowledged in a letter to the court that the woman made “a series of false, misleading and inconsistent statements about the facts of this case and about collateral or unrelated matters,” and that most troubling, “she made some false statements under oath.” The letter asked the court to allow a special prosecutor to be assigned to the case.

When the judge denied the request, Mr. Gonzalez’s office shifted gears and prepared a new case for a grand jury to review, this time without the woman’s testimony, officials said. The grand jury returned an indictment on the lesser charges.

From the start, the case had presented an unusual legal challenge for prosecutors: Under a loophole in state law — one that has since been closed — it was not illegal at the time of the reported attack for the police to have consensual sex with someone in their custody. To prove rape, the prosecutors would have had to show the men used physical force or threats to compel the woman to have sex.

Up until December, the prosecutors maintained there was strong evidence the woman had been sexually assaulted. They pointed to semen found on the woman’s body that proved a sexual encounter had taken place with both men, and to evidence the woman was in handcuffs during the alleged assault. In addition, the woman had never wavered in her assertion that she had been forcibly raped.