An Islamic faith school's policy of segregating boys from girls is unlawful sex discrimination, leading judges have ruled.

Three Court of Appeal judges in London overturned last year's finding by a High Court judge that Ofsted inspectors were wrong to penalise the mixed-sex Al-Hijrah school in Birmingham on the basis of an "erroneous" view that segregation amounted to unlawful discrimination.

In a test case ruling on Friday, the Master of the Rolls Sir Terence Etherton, Lady Justice Gloster, and Lord Justice Beatson unanimously allowed a challenge by Ofsted's chief inspector Amanda Spielman against Mr Justice Jay's decision.

The ruling will affect other schools which have a segregation policy. The appeal judges held that the school's policy of complete segregation from year five caused detriment and less favourable treatment for both male and female pupils by reason of their sex, and was contrary to the 2010 Equality Act.

For religious reasons the voluntary-aided school, which has pupils aged between four and 16, believes that separation of the sexes from year five onwards is obligatory.

It has complete segregation of boys and girls from nine to 16 for all lessons, breaks, school clubs and trips.

Ofsted went to the Court of Appeal in July to challenge the High Court's decision that the Al-Hijrah policy of separating the sexes from year five does not constitute discrimination on grounds of sex under the 2010 Equality Act.