CAIRO - An Egyptian court Tuesday ordered the country's military rulers to stop the use of "virginity tests" on female detainees, in a rare condemnation by a civilian tribunal of a military practice that has caused an uproar among activists and rights groups.

The virginity-test allegations surfaced after a March 9 rally in Cairo's Tahrir Square that turned violent when men in plainclothes attacked protesters, and the army cleared the square. The rights group Human Rights Watch said seven women were subjected to the tests.

The ban came a week after public outrage over scenes of soldiers dragging female protesters by the hair, stomping on them, and stripping one half-naked in the street.

"This is a case for all the women of Egypt, not only mine," said Samira Ibrahim, 25, who was arrested and spoke out about her treatment.

Ibrahim filed two suits against the practice, one demanding it be banned and another accusing an officer of sexual assault. She was the only one to complain publicly about a practice that can bring shame upon the victim in a conservative society.

A small group of women gathered outside the court building, holding banners. One said, "Women of Egypt are a red line."

The three-judge panel said in its ruling that the virginity tests were "a violation of women's rights and an aggression against their dignity."

The ruling also said a member of the ruling military council admitted to Amnesty International in June that the practice was carried out on female detainees in March to protect the army against possible allegations of rape, indicating it was an administrative order and not an individual decision.

Because the military is also acting as a police force, "it is the duty of the armed forces when carrying out these duties to abide by the law and not violate its provisions when dealing with citizens," the court ruling said.

The ruling "is incredibly important not only because it comes after scenes of sexual assault and battery of women by military troops," said Heba Morayef, an Egypt researcher with Human Rights Watch. "It is also important because it is the first time a civilian court acknowledged and criticized abuse by the military."