The administrative court on Tuesday ruled in favour of the girl’s parents who appealed a decision by school authorities to prohibit the headwear.
The court said the ban was “disproportionate” given that there was no evidence wearing the scarf, or hijab traditionally worn by Muslim women as a sign of modesty, caused any problems in the school or affected the teen's integration in the class, the SDA news agency reported.
The school invoked the ban in early summer last year.
But the court said this would only be justified if it became “a serious threat to the religious peace”, SDA reported.
The ruling also sided with arguments of the girl’s lawyer regarding freedom of religion, protected by federal and cantonal law, as well as the European Convention on Human Rights.
The decision came the same day that the federal government upheld the right of the canton of Ticino to forbid citizens in public from covering their faces with head veils, such as Burqas or Niqabs worn by some Muslim women.
Voters in the canton approved the ban in September 2013 with the support of the cantonal government.
The federal cabinet decided that the initiative is in line with the European Court of Human Rights, which earlier ruled that a veil ban in France was compatible with freedom of religion and non-discrimination.
The Ticino ban does not extend to headscarves.
The canton must now draft regulations to determine what penalties would apply to offenders.
The federal decision has emboldened a member of the right-wing Swiss People’s Party, MP Walter Wobmann to seek a popular initiative for a national ban on head veils, SDA said.
Islamic groups say they can live with such a ban.
“We would accept this because for us peace is extraordinarily important,” Hisham Maizar, president of the umbrella group for Islamic organizations in Switzerland is quoted as saying by broadcaster SRF.