The courtroom erupted in celebration and chants against military rule when the judge announced the verdict, Egypt Independent reports.
The issue surfaced in March following the arrest of demonstrators in Cairo's Tahrir Square. The rights group Human Rights Watch said seven women were subjected to the tests.
"This is a case for all the women of Egypt, not only mine," said Samira Ibrahim, 25, who filed two lawsuits after her arrest. One suit demanded the practice be ended and the other accused an officer of sexual assault, the Associated Press reports.
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."