Muslim students in Switzerland must shake their teacher's hand at the beginning and end of lessons, a regional authority has ruled.
A controversial exemption from the tradition had been granted for two teenage brothers whose interpretation of the Koran meant they were unwilling to touch a member of the opposite sex.
If they continue to refuse, their parents could face a fine.
The regional authority said teachers "had the right" to demand handshakes.
Shaking teachers' hands as a sign of respect is a longstanding tradition in Switzerland.
When it emerged last month that a middle school had allowed two Syrian brothers aged 14 and 15 to avoid the tradition due to their religious beliefs, it sparked a national controversy.
The boys, whose father is an imam, said their faith did not allow them to shake hands with a woman who was not related to them.
Justice Minister Simonetta Sommaruga said on television that "shaking hands is part of our culture".
There are about 350,000 Muslims in Switzerland, which has a population of eight million.
Some Swiss Muslim groups said there was no religious justification for refusing to shake a female teacher's hand and urged the Swiss not to give in to extremist demands. But one Islamic organisation said a handshake between men and women was prohibited.
The family's citizenship process was halted and the migration office in Basel said it was seeking more information about the circumstances under which the boys' father's asylum request was approved.
The school, in the small northern town of Therwil, had tried to find a compromise in the matter by deciding the boys should not shake hands with male or female teachers.
Later, after considerable media attention, the school turned to regional authorities to settle the matter.
The authorities said in a statement on Wednesday that "the public interest concerning gender equality as well as integration of foreigners far outweighs that concerning the freedom of belief of students".
The school said it was "relieved" at the ruling and that there was now "clarity on how to proceed".
In future, the parents or guardians of pupils in the northern canton of Basel-Country could face fines of up to 5,000 Swiss francs (£3,400; $5,000; 4,500 euros) if the pupils refuse to shake hands with a teacher.
The boys told Swiss media (in German) that "nobody could make them" shake hands with a woman, and that they "could not just delete their culture as if it were a hard drive".