An Egyptian court on 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 first 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 by force. The rights group Human Rights Watch said seven women were subjected to the tests.