Justice Arne Boyer ruled on Wednesday that the city state's so-called neutrality law, which bars the wearing of overt religious symbols and clothing for state employees on duty, weighed stronger than the right to free religious expression.
It found however that the young woman, who was not publicly named and did not appear at the court hearing, is allowed to continue teaching older vocational students in a Berlin public secondary school, AFP reported.
The ruling, which was still subject to a possible appeal, was expected to impact a wider debate on the issue in Germany, where rules on the hijab headwear differ between the 16 federal states.
German national law bans all civil servants from covering their faces, including with niqabs and burkas - except for health and safety reasons, such as fire-fighters wearing breathing masks.
But there is no nationwide ban on civil servants wearing the Muslim hijab headscarves, and many states weigh the tension between freedom of religion and civil servants' neutrality rules on a case-by-case basis.
The predominantly Catholic state of Bavaria recently ordered Christian crosses, which already hang on walls in schools and courtrooms, to also be fixed in the entrances halls of state administration buildings.