UK Government policy on young asylum seekers is unlawful and "creates a real risk" of children being wrongly detained, senior judges have ruled.

Home Office guidance states unaccompanied asylum seekers will not be accepted as being children if "their physical appearance and demeanour very strongly suggests that they are significantly over 18 years of age and there is little or no supporting evidence for their claimed age".

Lawyers for an asylum seeker from Eritrea, known only as BF, argued assessing someone's age based on their appearance or demeanour is "inherently unreliable" and therefore unlawful.

Giving judgment in London yesterday, the Court of Appeal ruled by a two-to-one majority that the Home Office's current policy "creates a real and avoidable risk of children being unlawfully detained".

Lord Justice Underhill said there is a "very substantial" margin of error of between five and seven years for an age assessment carried out on the basis of physical appearance or demeanour.

The judge held that the Home Office's guidance "fails to convey just how doubtful an assessment based on physical appearance and demeanour alone is", which he said "gave rise to a real risk of children being (unlawfully) detained".

He added: "In the absence of guidance as to the width of the margin of error, there is inevitably a real risk that immigration officers will place too much trust in their own assessment that a particular young person is 'significantly' over 18."

Ahead of the appeal, the Home Office amended its guidance, which now requires that two members of staff "have separately assessed that the individual is an adult" on the basis of their physical appearance and demeanour.

But Lord Justice Underhill ruled the amendments "do not address the specific deficiency" in the previous guidance, which was that there is "nothing to explain the width of the margin of error that has to be allowed for".

Lord Justice Baker agreed the amendments "do not address the central flaw" in the guidance, adding: "Given the evidence that the margin of error may be as much as five years, the word 'significantly' is so vague as to give rise to a real risk that young people under the age of 18 will be wrongly identified as adults."

Lord Justice Simon, giving a dissenting judgment, found the phrase "significantly over 18" did introduce "a degree of imprecision", but he ruled the policy was not demonstrably unlawful.

The court's ruling noted the Home Office had proposed to issue "revised interim guidance" on assessing the age of unaccompanied asylum seekers in the near future.

The judgment arose from legal action brought by BF, who said he arrived in the UK in 2014 in the back of a lorry.

BF told police he was 16 and wanted to claim asylum, but he was detained for nine months after immigration officers believed he was substantially over 18.

His solicitor Yen Ly, from Scott-Moncrieff and Associates, said her client was "utterly delighted" with the court's decision.

She said she thought the ruling would have "an impact on more than just his case", adding: "The judgment is clear and I do think that there are others who would have been detained who now will not be detained."

A Home Office spokesman said: "We are disappointed by the judgment and are considering its implications carefully."

Helen Johnson, head of children's services at The Refugee Council which provided evidence to the court, said: "We got involved in this case because every day we see children who have been deemed adult under this Home Office policy, leaving them feeling unsafe, frightened and unsupported.

"We are very pleased that the Court of Appeal agreed with us that the current wording of the policy does not provide sufficient guidance to ensure that children are not wrongly treated as adults.

"This ruling means that the Home Office must be much more cautious before it makes this decision and we hope that revised guidance will put an end to these errors once and for all."