The ruling, which cannot be appealed, has fuelled debate in Germany over whether schools should allow the niqab, a facial veil worn by Muslims which leaves only the wearer's eyes visible.
Hamburg education officials had ordered the girl's mother to ensure that her daughter did not wear the veil at school, a decision which an administrative court overturned on Monday.
State law does not currently permit the authorities to impose such a ban, the court said in a statement.
The teenager, who is studying retail sales, has “a right to unconditional protection of her freedom of belief” the statement added.
Hamburg's social-democratic education senator Ties Rabe immediately said that he would seek to change the state law.
“Only if students and teachers have a free and open face can school and lessons function,” he told local media.
German education laws are made at state level rather than by the federal government, but the case is part of a wider debate across the country.
High profile politicians in the conservative CDU, the economically liberal FDP and the far-right AfD have all voiced support for a niqab ban in the past, but others remain divided on the issue.
The state parliament in neighbouring Schleswig-Holstein failed to pass a ban on full-face veils in its universities and colleges on Monday, after the Green Party voted against it.