The headteacher of an independent Islamic school has been forced out to spare it from closure after a raid by armed police uncovered weapons and more than £400,000 in cash at a flat in the grounds.

Officers were called to the Darul Uloom school in Chislehurst on May 30 after reports of a man brandishing a gun. Headteacher’s son Yusuf Musa, who was the school’s designated safeguarding staff member, was arrested in connection with the incident.

Officers found a toy gun at his flat as well as bladed weapons and more than £400,000 in cash, Westminster magistrates’ court heard.

Headteacher Mustafa Musa was arrested the following day on suspicion of money laundering , sparking an emergency application by the Department for Education to shut the school. Government officials told the court they were concerned about the safety of the 155 pupils and applied for an order to suspend the school from the official register.

At court this morning, the school fended off the closure bid by agreeing that Mr Musa, and his son, will have “no involvement whatsoever” with the school in the future.

The two men are now banned from the grounds, including Yusuf Musa’s flat, and accommodation for pupils who pay £3,000-a-year fees as boarders.

The school may be shut temporarily until a government-approved trustee has been appointed to handle safeguarding. An independent safeguarding audit must be carried out and the school must accept and act on any recommendations, the court heard.

Chief magistrate Emma Arbuthnot, who was due to hear the application, said: “I had real concerns and understand why the department brought the application. I had a concern about what £400,000 was doing in cash at the school — I think that’s a danger to the school. If all the parents know they send money in and pay their fees in cash, that is a risk to the school. I would like there to be a bank account.”

The school has failed a series of Ofsted inspections in the past two years, when serious problems with its safeguarding and leadership were identified.

Gavin Irwin, the lawyer representing the school, told the court there have been “very positive and meaningful safeguarding improvements in recent weeks”.

“It’s a steady, if perhaps too slow, improvement,” he said.

The two men were questioned by police and remain under investigation. They have not been formally charged with any offence.

John Hartley, from solicitors Hodge Jones & Allen, which represents the school, said trustees "take their responsibilities for safeguarding children extremely seriously".

"They have made significant structural changes to the school’s leadership and will keep the safeguarding of those children in its care under constant review," he said.

"However, they are pleased that the court has recognised improvements have been made and that there are no immediate reasons for the school to be permanently closed.”