Home Secretary Theresa May has suffered a second defeat in a damages fight with an Iranian immigrant detained by officials after arriving in England on the back of a lorry.
A judge had concluded that the 20-year-old man - who was 16 when he arrived three years ago - had twice been unlawfully detained, following a High Court hearing in London in July 2014.
And a Home Office appeal against that ruling was today dismissed.
Three appeal judges ruled against Mrs May - following a Court of Appeal hearing in London.
They said the amount of the damages the man, who was not identified in a written appeal court ruling, would get had yet to be decided.
Judges heard that the teenager had been seen getting out of a lorry on the A2 in Kent on July 2 2012 - and had been arrested by police.
A short time later he had been detained under immigration legislation and taken to a Home Office "enforcement unit" in Dover.
Deputy High Court Judge Simon Picken had, in July 2014, concluded that Home Office officials had unlawfully detained the teenager for an hour and 20 minutes on July 2.
He also concluded that they had later unlawfully detained him for 25 days - between July 17 and August 10 2012.
The three appeal judges - Lady Justice Black, Lord Justice Tomlinson and Lord Justice Burnett - endorsed Judge Picken's ruling.
They said a central issue had been the teenager's age at the time he arrived in the UK.
He had given immigration officials his date of birth as September 21 1995 - and said he was 16.
Immigration officials had subsequently handed him into the care of social services staff.
He had stayed in the care of social services staff until July 17.
During that time staff had assessed his age and concluded that he had been born in 1993 not 1995 and was "an adult".
He had then once more been detained by immigration officials.
His lawyers then challenged the age assessment and provided copies of his birth certificate, national identity card and Iranian school certificate.
Social services staff had re-assessed his age and concluded that he was 16 - the age he had originally claimed - and he had been released from immigration detention on August 10.