Two police officers accused of raping a teenager while she was in custody resigned on Monday, the New York Police Department said.

The two former NYPD detectives – Eddie Martins, 37, and Richard Hall, 33 – are facing dozens of criminal charges and a possible $50 million lawsuit after the teenager accused them of raping her while she was handcuffed inside a police van. The indictment followed a weeks-long investigation of the two former officers, who, prosecutors said, pulled over a car driven by the 18-year-old, arrested her for drug possession, then took turns raping her in the back seat.

The resignation came three days before the officers were scheduled for a departmental trial, a separate proceeding from a criminal trial. During that process, officers are tried on charges of misconduct. A trial commissioner decides if they're guilty and makes recommendations to the police commissioner.

In a sharply worded statement, New York City Police Commissioner James P. O'Neill said he would've immediately fired Martins and Hall if they're found guilty at the departmental trial.

"And I would have done so on behalf of every NYPD cop, because we owe the communities we serve – as well as the honest, hardworking men and women of this department – nothing less," O'Neill said.

He also said: "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 price in service to New Yorkers."

John Arlia, Hall's defense attorney, said Monday that both officers jointly decided to resign to focus on the defense of their case and avoid the distraction of an administrative proceeding, which typically happens after the criminal matter is resolved.

Martins and Hall, who were members of the NYPD's Brooklyn South narcotics unit, have been charged with rape, sexual abuse, sexual misconduct, official misconduct and coercion. In total, they are facing 50 charges each.

DNA recovered from the victim after a rape-kit test matched samples taken from Martins and Hall, officials said. Surveillance footage also showed the teen getting out of the police van about 40 minutes after she was pulled over, prosecutors said.

The arrests and the former officers' arraignment hearing on Oct. 30 capped off weeks of serious allegations of misconduct that have been circulating in the media.

Acting district attorney Eric Gonzalez called the crimes a "flagrant betrayal of public trust" and vowed to hold the detectives accountable.

The detectives' attorneys raised doubts about the teen's account of what happened, suggesting during the court hearing that the encounter was not rape but consensual sex, the New York Times reported.

Prosecutors said the crimes occurred the night of Sept. 15, when the officers were riding in an unmarked Dodge Caravan as part of a buy-and-bust operation in South Brooklyn. The two detectives, who were in plain clothes at the time, left their post without their supervisor's permission at about 7:30 p.m. and drove to a park in Coney Island, according to the Brooklyn district attorney's office.

A little later, the officers pulled over the teen, who was with two male passengers, and found marijuana in the cup holder next to the front seat, prosecutors said. (The Washington Post generally does not identify people who are or may have been victims of sexual assault.)

They then handcuffed her and let the two passengers go before driving off with the teen in the back of the van, prosecutors said.

Before they left, the officers allegedly told the passengers to pick up their friend at the Coney Island police precinct in three hours.

While in the van, Martins called the teen's friends from his cellphone and told them not to follow the police vehicle, Assistant District Attorney Frank DeGaetano said during the hearing, according to the Times.

As Martins sat in the back seat with the teen, he told her that he and his partner were "freaks" and asked what she would do to get herself out of trouble, prosecutors said. Martins then forced the teen to perform oral sex on him and raped her while Hall drove and watched in the rearview mirror, prosecutors said.

The teen cried and pleaded for the officer to stop, DeGaetano said in court.

The van allegedly stopped in Bay Ridge, roughly four miles from where the teen was pulled over. There, the officers switched places and Hall forced the teen to perform oral sex on him, prosecutors said.

The detectives then drove to the Coney Island precinct and dropped the teen off after ordering her not to talk about the incident, prosecutors said.

The young woman's private attorney, Michael David, said his client has filed a notice of claim against the police department, the two former officers, their supervisor and the city of New York – the first step in filing a lawsuit. She's seeking $50 million in damages, David said.

Mark Bederow, an attorney for Martins, said he was confident that the teen's allegations will be "demonstrated to be false."

"I would urge people to respect the presumption of innocence, which applies to anyone, including a police officer," Bederow said, adding, "It will become crystal clear that Eddie Martins did not engage in any rape or forcible sex attack on the young woman."

Arlia, Hall's attorney, declined to comment about the case and, instead, referred to statements he'd made in court.

Martins and Hall, who are out on bail, are scheduled to appear in court in January.