The young couple and a male friend who took the photos had been held in a juvenile detention centre in the northern city of Nador since Thursday, as their arrest sparked outrage on social media.
After the detainees formally asked to be released, the judge on Monday agreed to their request and ordered that they be delivered to their parents, the public prosecutor said.
The teenagers, aged between 14 and 15, were arrested after a Moroccan NGO filed a lawsuit at the end of September which charged that the photos “deeply affect Moroccan education and culture, and upset people’s feelings.”
The teens’ lawyer, Moneim Fettahi, told AFP they were due to stand trial on Friday for public indecency.
The photographs were taken outside the high school in Nador where the three accused are students.
Young people have posted similar photos on social media and called on Facebook for a “giant kiss-in” on Wednesday in the coastal town of Mohammedia.
“Let’s mobilise against the arrest of these two teenagers … and fight against this backward, medieval mentality,” said the organisers of the event.
A similar group smooch, dubbed “free kiss,” is planned in Rabat on Saturday outside parliament.
Morocco has a reputation for religious tolerance and personal freedoms, particularly when compared to other Muslim countries, but it remains a deeply religious society.
Under article 483 of the kingdom’s penal code, anyone found guilty of violating public decency risks up to two years in prison.