Australia's High Court has ruled that a government plan for a refugee "swap" with Malaysia is unlawful.
Under the deal, Australia would have sent 800 asylum seekers to Malaysia and would have received 4,000 refugees in return over four years.
But the High Court ruled that Malaysia did not offer adequate protection for refugees in law, in what correspondents called a "huge blow" to the government.
Immigration Minister Chris Bowen said he was deeply disappointed.
"Let's make no bones about it: Today's decision by the High Court is a profoundly disappointing one," Mr Bowen told reporters.
"It is a significant blow to our efforts to break the people smugglers' business model," he added.
The court's ruling was praised by refugee advocates - and there are reports that asylum seekers held at Australia's detention centre on Christmas Island in the Indian Ocean clapped when they heard of the judgement.
The "Malaysian Solution" had intended to deter asylum seekers and the people smugglers who sell them passage to Australia - as well as combat perceptions that the Labor government of Prime Minister Julia Gillard was soft on asylum seekers, observers said.
It would have seen up to 800 people arriving "irregularly" in Australia by boat after 25 July 2011 transferred to Malaysia for "refugee status determination", explains a page on Australia's immigration department website.
There they would join a queue of refugees already seeking resettlement.
Meanwhile, Australia would have expanded its intake of refugees to include a further 4,000 refugees who entered Malaysia before 25 July 2011.
This was supposed to send a tough message to boat people that they would not be processed in Australia and they would not receive "preferential treatment" over other asylum seekers.
But in a 6-1 ruling, the High Court accepted the argument made by lawyers for two Afghan asylum seekers that the exchange was illegal as Malaysia, which is not a signatory to the UN convention on refugees, offered inadequate legal protections for asylum seekers.
It said Australia would fail to meet its international obligations under the terms of the deal.
It also said Immigration Minister Chris Bowen had no legal power to remove from Australia asylum seekers whose refugee claims had not yet been processed.
Malaysia has already begun sending registered refugees to Australia, and the decision leaves hundreds in legal limbo, reports said.
In a separate development, fires have broken out during a "disturbance" at an immigration detention centre in northern Australia.
Police and firefighters were attending the centre in Darwin, which houses 466 men, reported AFP news agency.
One blaze had been extinguished but another had broken out, an Immigration Department spokeswoman told AFP.
Local news reports said the fires were lit after Indonesian detainees reacted angrily to being unable to celebrate the Muslim festival Eid.