The European Court of Human Rights accepted that the refusal by authorities to exempt girls from the lessons interfered with their freedom of religion.
But the interference, it said, was justified by the need to protect the children from social exclusion.
School plays "a special role in the process of social integration, particularly where children of foreign origin were concerned," ruled the court, which is based in the eastern French city of Strasbourg.
The case was brought by a Turkish-Swiss couple who argued that forcing their pre-pubescent daughters to attend the classes violated their faith.
Also Read
The court found that the Basel authorities had tried to accommodate the parents' beliefs by, for instance, allowing the girls to wear the full-body "burkini" swimsuit.
The court also said that the fine of 1,400 Swiss francs (around 1,300 euros) imposed on the couple in 2010 after a warning was "proportionate to the aim pursued" of getting them to comply with the regulation.
All their appeals were rejected by Swiss courts, after which they took their case to Strasbourg.
Today's ruling is not final. The couple has three months to appeal the decision.
Disclaimer: No Business Standard Journalist was involved in creation of this content