The Government's move to close a residential girls' school in Nelson was unlawful, a judge has ruled.
Education Minister Hekia Parata has proposed shutting Salisbury School and moving the pupils to a boys' school in Christchurch next year.
The school sought a judicial review.
It argued sending the girls to a co-educational school would put them at risk and said there were questions over whether legislative tests had been met.
Justice Dobson said the decision disregarded "the prospect of greater risk of sexual or physical abuse" to the girls if they were sent to a co-ed special-needs school.
Parata is preparing a response.
Salisbury has been open since 1914 and has a roll of 80 pupils from around the country.
Should schools be using dogs to detect drugs?Related story: Demand rises for drug dogs at schools