The highest court in Germany has ruled that a Muslim teacher has the right to wear a headscarf in class.
But the court also ruled that new laws could be passed in German states banning the practice.
Thirty-one-year-old Fereshta Ludin, who is originally from Afghanistan, was denied a job in the state of Baden-Wuerttemberg in 1998 because she insisted on keeping her head covered in school.
The state said her headscarf would contravene Germany's constitutional religious neutrality, an argument which was upheld by a lower federal court last year.
Ms Ludin argued that the constitution guaranteed religious freedom.
The German Constitutional Court has now ruled by five votes to three that, under current laws, she can wear the scarf - but it says German states should seek to find an acceptable balance in law between religious freedom and neutrality in schools.
"The state legislatures are now free to provide the legal basis that has been missing until now," the ruling said.
However, the BBC's Tristana Moore says Ms Ludin is not the only Muslim woman to be refused employment at a state school because of her headscarf, so her case will have far-reaching implications.
'Symbol of exclusion'
Correspondents say the case involves a clash of two key German legal concepts - religious freedom for all and the right of children to have a religiously-neutral education.
Ms Ludin was refused a job in 1998 - despite successfully completing an internship at a high school near Stuttgart.
Baden-Wuerttemberg education minister Annette Schaven argued that the headscarf was political and "understood as a symbol of the exclusion of woman from civil and cultural society".
Ms Ludin now works at a private Islamic school in the Kreuzberg district of Berlin, which has a large ethnic Turkish population.
She said the state was equating the headscarf with "things I already distanced myself from during my own school years".
The decision follows a similar ruling in August, when the court said a department store in Frankfurt was wrong to sack a Muslim woman who wanted to wear a headscarf to work.
The store dismissed her on the grounds that her headscarf would "antagonise rural customers".