The European Court of Human Rights upheld a decision of a Swiss court backing fines on Muslim parents who refused to allow their daughters to take part in mixed swimming lessons on the basis of their religion.

The parents, both Turkish-Swiss dual nationals, appealed to the court over a fine handed down by education authorities after they declined to send two of their daughters to mixed swimming lessons.

They said that the requirement, imposed by the school up until the age of puberty as part of its physical education curriculum, violated their right to freedom of thought, conscience and religion enshrined in article 9 of the European Convention on Human Rights.

While the court acknowledged that the requirement was an interference with the freedom of religion, it ruled that the interference represented a "legitimate aim" to protect foreign pupils from social exclusion.

READ MORE: Swiss anger at Muslim boys over female handshake snub

It said that schools played an important role in encouraging social integration, especially regarding children of foreign origin.

It also noted that the authorities in Basel, Switzerland, had tried to reach a compromise with the parents, including allowing the girls to wear burkinis for the lessons.

The court also ruled that the fine imposed on the parents, of 350 Swiss francs ($345) each per child, totalling 1,400 francs, was proportionate to the aim.

The European Court of Human Rights was established to oversee the European Convention on Human Rights, adopted by the 47-member Council of Europe.

The court is not a European Union institution.