Muslims parents in Switzerland may not exempt their girls from having swimming lessons with boys, the European Court of Human Rights has ruled after a hearing.
The court, based in in Strasbourg, France, said that Swiss authorities had acted legally by giving precedence to enforcing "the full school curriculum" and the children's "successful integration" into society.
The court rejected the case brought by a Muslim couple in the Swiss city of Basel who cited religious reason in wanting their two elder daughters, pre-pubescent at the time, to sit out swimming lessons with boys.
In its statement the European court said the refusal to exempt the girls had interfered with the right to freedom of religion.
But it also said the law involved was designed to "protect foreign pupils from any form of social exclusion" and Switzerland was entitled to design its education system according to its own needs and traditions.
Schools, it said, play an important role in social integration, and exemptions from some lessons are "justified only in very exceptional circumstances."
The Muslim couple who brought the case are both Swiss nationals, of Turkish origin, refusing to send their daughters to the compulsory mixed lessons in the city of Basel.
In 2010, the parents were fined 1,400 Swiss francs ($1,382) in the first move of its kind after they withdrew their daughters aged seven and nine from the school swimming lessons. They also lost their appeal at a cantonal (state) administrative court a year later.
The Basel court stated that it was greatly "in the public interest that all children, including girls of the Muslim faith, go to school swimming lessons."
It said this was not only so that they should learn to swim but also because such lessons encouraged socialization and integration.
The European Court of Human Rights' decision described the parents as "fervent practitioners of the Muslim religion."
The parents had said it was against their religious convictions to send their children to mixed swimming classes and that it violated Article 9 of the European Convention on Human Rights on the freedom of religion.
They argued the school had rejected their request for their daughters to attend single sex swimming classes in another school.
In their defense the parents said although the Qur'an does not call for the female body to be covered until puberty, their beliefs "required them to prepare their daughters for precepts that would be applicable from puberty."
In 2016, officials in Basel suspended the citizenship process for the family of two teenage Muslim brothers who refused to shake hands with female teachers.
Switzerland has also applied the law to other cases - a man of Bosnian origin was fined last year for refusing to allow his daughter to take part in swimming lessons during school hours, among other activities.
Muslims account for around 5.6 percent of Switzerland's 8.2 million people while more than 70 percent of the polulation consider themselves to be Christians.