The Home Office's decision to house cross-channel migrants in a "squalid" barracks in Folkestone was unlawful, the High Court has ruled.
Six asylum seekers brought the case, claiming Napier Barracks was "unsafe" and dormitory use caused a Covid-19 outbreak earlier this year.
The ruling could see a damages claim against Home Secretary Priti Patel.
The Home Office said use of the barracks would continue, and it was considering its "next steps".
The judgment could lead to further cases from any other men held at the camp who can bring similar evidence to court.
Mr Justice Linden's judgment looked in detail at a fire that broke out at the site in January, and when nearly 200 people contracted coronavirus during an outbreak at the camp.
The ruling followed hearings that took place in April.
The judge said: "I do not accept that the accommodation there ensured a standard of living which was adequate for the health of the claimants.
"Insofar as the defendant considered that the accommodation was adequate for their needs, that view was irrational."
By Dominic Casciani, home and legal correspondent, BBC News
One of the crucial questions about Napier is why it was allowed to open in the way it did, given Public Health England (PHE) had warned the Home Office the dorms would not be suitable.
During the High Court hearing in April, there was no witness statement from PHE or Clearsprings - the Home Office contractor running the site - about how a plan was developed to manage Covid-19 risks.
The judge found civil servants appreciated the risks existed, but it's not clear how they took on board the "significant problem" PHE warned of, given they also needed to get the best value of money out of the site.
The "bottom line", said the judge, was the arrangements were contrary to PHE advice and did not even implement measures which the Home Secretary herself had apparently regarded as desirable and feasible.
Read more from Dominic here.
Mr Justice Linden also criticised the "detention-like" setting for the men.
He said: "They were supposed to live voluntarily pending a determination of their applications for asylum.
"When this is considered, a decision that accommodation in a detention-like setting - a site enclosed by a perimeter fence topped with barbed wire, access to which is through padlocked gates guarded by uniformed security personnel - will be adequate for their needs, begins to look questionable."
Following the ruling, campaigners, including human rights group Liberty, Refugee Action and the Joint Council for the Welfare of Immigrants, called for the immediate closure of the site.
Liberty lawyer Lara Ten Caten said: "The government's only response can be to close it down immediately."
Refugee Action and the JCWI accused the government of being reckless with people's lives.
Yvette Cooper, home affairs select committee chairwoman, said Ms Patel and the Permanent Secretary told the committee in February the Home Office was working "in line with public health guidance".
She said: "Clearly they were not. We have called on them both to come back before the committee at the earliest opportunity to explain the decisions they made and also the contradictions with the information they previously gave us in light of today's court ruling."
Men living at the barracks told the BBC conditions were inhumane.
One man, speaking through the fence at the site, said there was no hot water or electricity and only one shower for 100 people.
Lawyers from Deighton Pierce Glynn (DPG) had claimed the site - which they said still housed more than 265 people - had breached the migrants' human rights.
The firm said despite emptying the barracks in early April 2021 and amid ongoing concerns from public health officials that the site could not be made Covid-19 secure, the Home Secretary began refilling the site.
DPG said residents are sleeping in dormitories of up to 12 people and lawyers understood the intention was to fill the barracks to over 300.
In April, the court heard public health experts had repeatedly raised concerns about the use of the site during a pandemic, while an independent report found seven suicide attempts and seven incidents of serious self-harm.
Failings at the barracks included:
- Lack of ventilation
- Run-down buildings
- Use of communal dormitories during a pandemic
- Significant fire risks
- 'Filthy' facilities
- 'Decrepit' isolation block not fit for habitation
Tom Hickman QC, representing four claimants, previously told the court the site was "squalid, ill-equipped, lacking in personal privacy and unsafe".
Lisa Giovannetti QC, representing the Home Office, said clinically vulnerable people had been "sifted out".
She said Ms Patel had decided the barracks could be used safely by "introducing safeguards".
But in a statement read to the court, one of the claimants, who was later moved to other accommodation, said: "The situation in the camp is very bad and degrading."
"Detainees in the barracks including myself have lost hope."
The judge declined to rule the barracks could never be used to house asylum seekers, but called for "substantial improvements".
The Home Office and the six men have yet to agree on damages.
A Home Office spokesman said: "During the height of the pandemic, to ensure asylum seekers were not left destitute, additional accommodation was required at extremely short notice.
"Such accommodation provided asylum seekers a safe and secure place to stay. Throughout this period our accommodation providers and sub-contractors have made improvements to the site and continue to do so.
"It is disappointing that this judgment was reached on the basis of the site prior to the significant improvement works which have taken place in difficult circumstances."