Two Los Angeles police officers pleaded no contest Monday to sexually assaulting multiple women, often preying on victims while one partner served as the lookout as the other carried out an attack in their unmarked police car.

In a downtown L.A. courtroom, Officers Luis Valenzuela and James C. Nichols entered their no-contest pleas to two counts each of forcible rape and two counts each of forcible oral copulation. The officers appeared in court in orange, jail-issued jumpsuits and were shackled at the waist.

“This hurts,” Los Angeles County Superior Court Judge Ronald S. Coen said as he alluded to his own career in law enforcement and handed each man a 25-year term in state prison. The judge also ordered the officers to register as sex offenders.

If tried and convicted, the men had faced a maximum penalty of life in prison.

The Los Angeles County district attorney’s office had filed more than a dozen felony counts against the men in 2016, alleging they targeted four women from 2008 to 2011 by forcing them to have sex. Valenzuela was also accused of assaulting one woman with a gun. Most of those charges were dismissed as part of Monday’s plea deal.

The victims were women ages 19 to 34 who were informants for drug investigators or had been recently arrested on suspicion of drug-related crimes. Some of the women said they feared arrest if they did not obey Nichols’ and Valenzuela’s orders. The Times does not generally identify victims of sexual violence.

“How dare they. They wore a badge to protect people and instead they terrorized them,” Det. Carla Zuniga, one of the lead investigators in the case, said outside the courtroom. “They tarnished the public trust. People trust the police. Every time something like this happens, we have to walk into the community and say, ‘No, that’s not us.'”

Nichols, 46, and Valenzuela, 45, were put on unpaid leave from the Los Angeles Police Department in 2013 and had been relieved of duty. Monday’s plea deal clears the way for their formal termination. They have been jailed since early 2016, when LAPD detectives arrested them on felony charges.

Stewart Powell, Nichols’ defense attorney, said his client was “looking forward to his day in court” but accepted the plea so the case could close.

“It gives him a chance to get out and have a life after this case,” Powell said.

Valenzuela’s defense attorney, Bill Seki, said the plea deal allowed his client to one day reunite with his kids outside prison. Valenzuela, he said, was “pretty somber” before entering his plea.

“As the cases go, these times are tough for police officers,” Seki added.

The Times first reported on the misconduct allegations in 2013, when detectives sought a search warrant to seize computers and phones, part of an exhaustive investigation that involved scouring the officers’ work with drug informants in the Hollywood area.

Prosecutors sought to identify every possible woman who encountered the two.

“We do believe there may have been additional victims who chose not to cooperate with the investigation,” said Deputy Dist. Atty. Ann Marie Wise.

The first woman to accuse Valenzuela and Nichols came forward three years earlier. She said that the officers picked her up in December 2008 for her work as an informant, where she’d score drugs and in exchange receive $40.

While in the back seat of the officers’ Volkswagen Jetta, she testified at a 2017 court hearing, Nichols exposed himself and asked that she touch him. Then, he pushed her head into his lap, she said.

Another woman said that after she was arrested in 2009 on suspicion of dealing heroin, the officers transported her from Hollywood to the LAPD jail in Van Nuys. She testified that Nichols and Valenzuela took a detour and stopped in an alley.

Valenzuela informed her that there was a way she could stay out of jail, and he had sex with her in the back seat of the Jetta, she testified. Nichols waited outside the car.

“I was in a dark alleyway with a guy with a gun,” she testified. “I didn’t really feel like I had a choice.”

She was subsequently released and did not have to post bail.

LAPD Sgt. Greg Bruce said at a 2016 court hearing that another woman had sex with the officers several times in a bid to “earn points” and have a drug case dropped.

“He told her if she had sex with him, it would count towards her working off her case,” Bruce said on the witness stand.

The woman obeyed out of fear that she’d end up again behind bars.

“What’s clear from all of the witnesses that the court heard is that these officers placed these women in a situation where they were extremely vulnerable,” said Wise, the prosecutor. “They’re in a situation where they don’t have a choice. They have the threat of either going back to jail or somehow being penalized by these officers if they don’t comply.”

All four women who accused the men of forcing them to have sex filed civil lawsuits, and so far the city has agreed to pay a total of more than $1.8 million in settlements to three of the women.

The fourth woman’s case is still pending.

The directors of the Los Angeles Police Protective League, the union representing rank-and-file officers, called both officers’ actions “disgusting” and said there was “zero tolerance” for officers who use their position to take advantage of others.

“We are sorry these women were let down and hope they are healing as best they can,” the union leaders said in a statement.

Before the sentencing, Monday, one of the victims stood before the judge and spoke of her difficult road to recovery. She said she was unable to trust others or feel safe.

Some of her worst panic attacks, she said, had two triggers: the sight of a police car or a Volkswagen Jetta.