In a statement explaining the decision, the court said the law “contravened the principle of equality in relation to freedom of religion, belief and conscience”.
The law prevented girls younger than 10 from wearing the headscarf and had been challenged by two children and their parents.
The measure was passed in May 2019 under the previous coalition of the centre-right People's Party (OeVP) and the far-right Freedom Party (FPOe), just days before that government collapsed due to a corruption scandal.
Both parties had made anti-immigration rhetoric and warnings against “parallel societies” a key part of their political messaging and their spokespeople made it clear at the time that the law was targeting the headscarf.
However, the text of the legislation attempted to avoid charges of discrimination by banning “ideologically or religiously influenced clothing which is associated with the covering of the head”. Nevertheless, the court said that the law could only be understood as targeting Islamic head coverings.
The OeVP-FPOe government had itself said that the patka head covering worn by Sikh boys or the Jewish kippa would not be affected.
The new OeVP-Green party coalition that took office in January had planned to extend the ban for girls under 14.
The current OeVP Education Minister Heinz Fassmann said that the ministry would “take note of the judgement and look into its arguments”.
“I regret that girls will not have the opportunity to make their way through the education system free from compulsion,” he added.
In its statement the court said that far from promoting integration, “the ban could… lead to discrimination as it runs the risk of making it more difficult for Muslim girls to access education and socially excluding them”.
The IGGOe, the body officially recognised as representing the country's Muslim communities, welcomed the judgement and said the court had ended “the populist politics of bans”.
IGGOe President Umit Vural said in a statement: “We don't condone disparaging attitudes towards women who decide against the headscarf… and we also cannot agree with the curtailing of the religious freedom of those Muslim women who understand the headscarf to be a integral part of their lived religious practice.”
The IGGOe had said at the time of the ban that in any case only a “miniscule number” of girls would be affected.