A federal court ruled that it was legal for Illinois guards to strip-search female inmates in full view of male correctional officers, male and female cadets, and civilians for a "training exercise."

The judges ruled 2-1 after hearing that the women were forced to remove their tampons while guards called them derogatory terms like "dirty b------," and told them they "smell like death."

In his dissenting opinion, Judge John Z. Lee wrote "It is rationales like this — that fall somewhere between legitimate security concerns and unjustified harassment — that suggest the continuing need for the Fourth Amendment even in prisons."

Visit INSIDER's homepage for more stories.

200 female inmates in Illinois' Lincoln Correctional Center were rounded up early one morning in 2011 by a tactical team in riot gear. They were handcuffed and brought to a gym where, "without being told what was happening or why," they were split into groups, brought into an adjoining bathroom, and one by one were asked to raise their breasts, bend over, spread their buttocks, and cough, according to The Washington Post.

Mensturating inmates were asked to remove their tampons. The search took place in front of male correctional officers, male and female cadets, and civilians. Throughout the process, the female correctional officers and cadets told the women they were "dirty b------," "f------ disgusting," "deserve to be in here," and "smell like death," according to the federal complaint that was being reviewed by the court.

The strip search was performed as a "training exercise." On Friday, The Hill reported that federal judges ruled the female inmates' privacy had not been violated in a 2-1 decision.

Read more: A sexual misconduct allegation from one of Jeffrey Epstein's victims sparked a quiet war between two of America's most powerful lawyers. Now it's about to blow up.

The controversial strip search training exercise resulted in an eight-year legal battle that reached the U.S. Court of Appeals for the 7th Circuit. Court documents detail the incident, during which many naked inmates "got blood on their bodies and clothing and blood on the floor," and were not given replacement sanitary pads or tampons.

Justification for the ruling was that the search was conducted by visual means, and therefore did not violate the inmates' Fourth Amendment rights. In his dissenting opinion, Judge John Z. Lee wrote otherwise.

"This mass strip search of female inmates was conducted solely for training purposes, but the training was not strictly necessary, as most cadets graduated without it," Lee wrote. "Surely a 'training' justification need not be treated with the same level of deference as a search conducted due to concerns over smuggled weapons or other contraband?"

Conversely, The Washington Post reported that on Friday, Los Angeles County settled a lawsuit for $53 million after a judge found that female inmates' Fourth Amendment rights were violated during a mass visual body cavity search in 2010. The county did not admit wrongdoing.

"It is rationales like this — that fall somewhere between legitimate security concerns and unjustified harassment — that suggest the continuing need for the Fourth Amendment even in prisons," Lee wrote in his opinion.