The court rejected the Government's declaration that Malaysia was a safe haven in which asylum seekers' human rights would be protected.
"Today the High Court held invalid the Minister for Immigration and Citizenship's declaration of Malaysia as a country to which asylum seekers who entered Australia at Christmas Island can be taken for processing of their asylum claims," the court said.
Although the Government could try to legislate around the decision, it would almost certainly fail in the face of resistance from the Opposition and the Greens, whose single Lower House MP is crucial for Gillard and who hold the balance of power in the Senate.
The court's decision may also affect backup plans to reopen former Liberal Prime Minister John Howard's "Pacific solution" detention centre on Papua New Guinea's Manus Island, or even Nauru.
Politically, the effective end of the Malaysian deal is a heavy blow to Gillard, whose failure to control the arrival of boatloads of asylum seekers has been an effective cudgel for Opposition portrayals of the Government as bungling incompetents.
Suffering consistent record lows in opinion polls, Gillard is under fire from all sides, including unions furious at her decision not to appoint an inquiry into the decline of the nation's manufacturing industries and the loss of thousands of jobs.
The court's decision has deepened the mire.
Shadow immigration minister Scott Morrison said the decision was a "devastating blow for a grossly incompetent Government".
"This is part of a continuing pattern of failure from a Government that just can't get anything right," he said.
Refugee groups welcomed the decision, but a spokesman for Malaysia's Home Affairs Minister told ABC radio that the decision had come as a surprise and the Government was waiting for details to see if the deal could be changed to make it legal.
The court had earlier granted an 11th-hour interim injunction preventing the removal to Malaysia of two asylum seekers who argued that Australia would be in breach of its international obligations because it could not guarantee Malaysia would protect their rights.
The court said that Malaysia was not legally bound to provide the required access and protections.
"The parties agreed that Malaysia is not legally bound to, and does not, recognise the status of refugee in its domestic law," it said.