Scotland's highest court has ruled that lock-change evictions of asylum seekers without court orders are lawful.
The judgment from the Inner House of the Court of Session backs up an earlier ruling.
It said Home Office contractor Serco did not act unlawfully when it issued eviction notices in Glasgow last year.
The Scottish Refugee Council said it was "bitterly disappointed" by the judgment, which left hundreds of people at risk of immediate homelessness.
They said the ruling meant that evictions without a court order - which are unlawful in Scotland - can now be carried out by Serco against people in the asylum system.
Robina Qureshi, from Positive Action in Housing, said the decision had legally instituted a form of "housing apartheid" in which one section of society had its rights protected but another did not.
Serco, which handed over the contract to Mears Group in September, is still housing about 150 people whose asylum applications have been turned down by the Home Office.
It said it would now proceed "in a considered and sensitive manner" to return these properties to their owners, mainly social housing landlords.
Throughout the summer Glasgow Sheriff Court granted 130 interim interdicts to delay the removal of failed asylum seekers until the outcome of the appeal was known.
Three judges on Scotland's supreme civil court have now ruled that it was not unlawful for Serco to evict an asylum seeker from her property without first obtaining a court order.
Scottish Refugee Council chief executive Sabir Zazai called for "fundamental and urgent reform" to the UK's asylum system.
Why are asylum seekers being evicted?
The Home Office - which is responsible for all UK immigration policy - provides asylum seekers with free accommodation under the UK government's dispersal programme, while their applications are being processed.
Until September, the contract was operated by private outsourcing firm Serco, which provided accommodation to about 5,000 people in Scotland, almost all of them in Glasgow.
When applications are refused, the asylum seekers no longer receive funding from the Home Office and Serco said it had been picking up the bill, sometimes for months.
What was the court case about?
The case dates back to summer 2018 when Serco began to issue failed asylum seekers with eviction notices telling them their locks would be changed as part of Serco's new "Move on Protocol".
Govan Law Centre brought the case against Serco and the UK home secretary in August 2018. After that failed, in April, it brought an appeal in the name of an Kurdish Iraqi national Shakar Ali.
Serco had planned to serve lock-change notices to more than 330 asylum seekers in the city but it paused the move after the legal challenge.
The number facing these lock-change notices is now lower because some people have been evicted and others have had their asylum application reinstated or received positive decisions.
What did the judgement say?
In the court opinion, Lady Dorrian wrote that the test case asylum seeker, Ms Ali, had no lease and paid no rent so her occupation of the property was "precarious".
The senior judge said: "The agreement under which she occupied the property made clear that her occupancy was temporary only, for the limited duration of the period, during which her asylum claim was being assessed."
Lady Dorrian said that once her application was turned down she only needed to be given written notice to quit the property and it did not require court procedure.
Serco's Julia Rogers said Scotland's highest court was clear that its approach was "completely proper and within the law".
She said Serco had been demonised and subject to extreme criticism despite spending millions of pounds supporting people who no longer had a right to remain in the UK.
The UK Home Office said if someone had no right to remain in the UK then there was no legal basis to continue to provide support.
However, it said it would still provide accommodation and support to those who would otherwise be destitute and who were temporarily unable to leave the UK because of practical or legal obstacles.