A ban on prayer rituals at one of the highest-performing state schools in England, famous for its strict discipline and high-profile headteacher, has been upheld by a high court judge.

The case against Michaela community school in Brent, north-west London, was brought by a Muslim pupil, known only as TTT in court proceedings, who claimed the ban was discriminatory and breached her right to religious freedom.

In a written judgment handed down on Tuesday , Mr Justice Linden dismissed the pupil’s arguments against the prayer ban on all key grounds. He upheld her challenge to a decision to temporarily exclude her from the school however.

The judgment followed a two-day hearing in January at the high court in London which heard the prayer ban was introduced in March last year by the school’s founder and former government social mobility tsar, Katharine Birbalsingh.

Lawyers for Michaela told the court the ban was introduced after the school found itself the target of death and bomb threats over its approach to religious observance after pupils were seen praying in the school playground by passersby. The prayer issue was also said to have triggered “an unprecedented outbreak of poor behaviour among pupils”.

Birbalsingh, who is often called Britain’s strictest headteacher, defended the policy, arguing that it was vital in order to “maintain a successful learning environment where children of all races and religion can thrive”.

The pupil claimed the prayer ban had fundamentally changed how she felt about being a Muslim in the UK. It was “like somebody saying they don’t feel like I properly belong here”, the court heard.

She also argued that the ban “uniquely” affected her faith due to its ritualised nature, and that Michaela’s policy on prayer was “the kind of discrimination which makes religious minorities feel alienated from society”.

After the judgment, the pupil, who cannot be named for legal reasons, said: “I am obviously very disappointed that the judge did not agree with me. As is set out in the judgment, I do not agree that it would be too hard for the school to accommodate pupils who wished to pray in the lunch break. The school is very well run and generally very good at managing everything. The school doesn’t wish to allow pupils to pray, has chosen a different path and the judge has found in their favour.

“Even though I lost, I still feel that I did the right thing in seeking to challenge the ban. I tried my best, and was true to myself and my religion. Being involved in this case has not been easy for me. My main focus now is my GCSEs. The teachers are very good here and I hope to do the best that I can. I am also grateful for the understanding that my non-Muslim friends at school have shown as to the issues that affect us.”

Katharine Birbalsingh, founder and headteacher of Michaela community school. Photograph: David Levene/The Guardian

The pupil’s mother, who also cannot be named, said: “I’m profoundly dismayed by the case’s outcome. The case was rooted in the understanding that prayer isn’t just a desirable act for us – it’s an essential element that shapes our lives as Muslims.

“In our faith, prayer holds undeniable importance, guiding us through each challenge with strength and faith. Even though she’s studying for her GCSEs, my daughter’s impassioned stance compelled me to support her, and I stand firm in that decision. Her courage in pursuing this matter fills me with pride, and I’m confident she’s gained invaluable lessons from the experience.”

Birbalsingh welcomed the court’s decision as a victory for all schools. She said: “A school should be free to do what is right for the pupils it serves. Schools should not be forced by one child and her mother to change its approach simply because they have decided they don’t like something.”

She said families choose Michaela not just because of its results. “They choose Michaela because they recognise that our traditional values create a school environment that is a joy to be in. Our children are happy and are friends with each other across racial and religious divides.”

She went on: “If parents do not like what Michaela is, they do not need to sent their children to us,. Can it be right for a family to receive £150,000 of taxpayer-funded legal aid to bring a case like this?”

The education secretary, Gillian Keegan, said: “I have always been clear that headteachers are best placed to make decisions in their school.

“Michaela is an outstanding school and I hope this judgment gives all school leaders the confidence to make the right decisions for their pupils.”