LOS ANGELES -- Two veteran Los Angeles police officers who sexually assaulted women while on duty have each been sentenced to 25 years in prison.

James Nichols, 46, and Luis Valenzuela, 45, entered no contest pleas Monday as they were set to stand trial on charges of rape and forced oral copulation.

The Los Angeles County district attorney's office says the men, who were partners on the force, assaulted four women between 2008 and 2011.

Get Breaking News Delivered to Your Inbox

The victims ranged from 19 to 34 years old and all were involved in drug-related investigations. At least one of the victims acted as an informant for the police, reports CBS Los Angeles.

The women accused the officers of pressuring them to perform sex acts to avoid going to jail, saying they were attacked in alleys, apartments and the officers' patrol car.

One victim said that she was sexually assaulted on four separate twice by Nichols, once by Valenzuela and once by both of the officers, all taking place over a period of about 18 months.

Another woman accused Valenzuela of assaulted her with a gun.

After the plea deal was accepted, a deputy district attorney called the crimes "particularly heinous" because of the authority officers have when they put on their badge.

"Prior to being a judge, over 33 years ago, I was in law enforcement as a member of the DA's office and head of organized crime," said Los Angeles Superior Court Judge Ronald S. Coen to the former cops while in court, reports CBS Los Angeles. "This hurts."

Since being arrested in February 2016, both Nichols and Valenzuela have remained in jail. The two were placed on unpaid leave from the LAPD in 2013 and had been relieved of duty, reports the Los Angeles Times.

The plea reportedly paves the way for their formal termination.

Last year, the Los Angeles City Council agreed to pay nearly $2 million to settle lawsuits brought by the women.