Parents of pupils fighting to save a primary school in west Wales have lost their appeal in Cardiff's High Court.
There has been a long-running campaign to keep the school
Pembrokeshire council made the decision to shut Hermon Community Primary School last September.
But parents mounted a strong campaign to reverse the move, arguing it could spell the end for rural schools in the county.
They say they are determined to fight on and hoped to find a way to run the school independently.
Hermon school, which has 53 pupils, remains due to close next month.
The judge Mr Justice Jack said he admired the parents' fight, but that it was not up to the court to decide policy.
He said that was up to the government, and said Pembrokeshire council had been fair in its dealings with Hermon school
One of the parents, Michelle Fletcher, said they were "devastated" by the decision.
"It is so disappointing for the whole village, the whole area," she said.
"The school is so strong, the numbers are growing, we just feel really upset.
"We all stick together - you probably haven't seen the last of us yet."
The council also wants to close schools at Blaenffos and Crymych and build a "campus for lifelong learning" on the old Crymych site.
Parents at the other two schools are reported to be in favour of this plan.
Welsh Education Minister Jane Davidson had refused an appeal by Hermon parents to keep the school open and gave her backing to the council's decision.
In April, campaigners won permission to mount their legal challenge, and they secured legal aid to cover the costs.
In June, the Welsh Assembly Government lost an appeal to prevent the judicial review, arguing that the parents' challenge should have been brought earlier.
Barrister Nicholas Bowen, representing the parents, had argued that the decision to close the school was unlawful and there was "no rational justification" for it.
A spokesman for the parents Cris Tomos said they hoped to apply for voluntary-aided status and to team up with a group in Cumbria in a similar situation.
He said his could let them run the school independently but with the help of local authority funding.
He said: "The land on which Hermon school is built was originally gifted for education purposes by our great-great-grandfathers so we are looking into whether that land can now be reclaimed.
"Then we wouldn't have to fight to justify our existence to a local authority that doesn't seem to be interested in community."