Scottish taxpayers are facing a £500,000 legal bill after the UK’s highest court ruled that parts of the SNP’s plan to assign every child a state guardian were ruled unlawful.

The Supreme Court has ordered the Scottish Government to pay the £250,000 costs racked up by the No to Named Person (NO2NP) campaign, which won a significant victory in July that forced ministers to put the scheme on hold.

With the Scottish Government’s own legal bill expected to be at least as much, the case is on course to cost the public purse around half a million pounds.

Simon Calvert, the campaign’s chairman, accused SNP ministers of wasting hundreds of thousands of pounds defending the flawed plan and argued the court’s decision to award cost to NO2NP was “a total vindication of the legal action.”

Under the legislation, passed last year, the NHS will appoint a health worker to act as the named person for every child under the age of five, with the responsibility passing to teachers and councils until they reach 18.

But the damning Supreme Court ruling found parts of the plan breached parents’ human rights by allowing information to be shared between public bodies without parental consent.