A Moroccan judge has acquitted two teenage girls put on trial for homosexuality, charges that angered LGBT rights groups who have long argued that same-sex relationships should not be a crime.

The girls, ages 16 and 17, had faced up to three years in prison according to a law forbidding "lewd or unnatural acts with an individual of the same sex." One of their mothers reported the two to police in October.

Related: Teen Girls In Morocco Face Jail For Kissing

The judge in Marrakech ruled Friday that the girls must remain under parental authority until they turn 18.

Their defense lawyer, Rachid El Ghorfi, expressed relief at the acquittal. Ghorfi says, "They should have never been in front of the prosecutor or the judge."

Women and girls rarely are charged under Morocco's law prohibiting homosexual activity.