(CNN) -- The High Court in Australia ruled Wednesday that the country cannot send asylum seekers to Malaysia.
The prime ministers of both countries had announced the agreement in May, saying it was aimed at reducing human smuggling and illegal migration to Australia.
Under the deal struck at the time, the next 800 asylum seekers who arrived in Australia illegally would be transferred to Malaysia for refugee status determination. In exchange, over the next four years, Australia would take in 4,000 refugees who are already residing in Malaysia.
Sixteen asylum seekers who were to become the first to be flown from the Australian territory of Christmas Island to Malaysia then filed suit.
Among the reasons the court cited Wednesday: Malaysia, unlike Australia, is not a signatory to the 1951 U.N. Refugee Convention.
The court said the country to which asylum seekers can be taken for processing has to be "legally bound by international law or its own domestic law."
It has to have proper procedures in place to assess an asylum seeker's need for protection, among other factors.
The court also said that Australia's immigration ministry did not have legal power to remove asylum seekers whose refugee claims have not been determined.
Thousands of refugees seek asylum in Australia each year, according to the Refugee Council of Australia, an umbrella organization for groups that support refugees.
Most of them come from Afghanistan, Sri Lanka, Iraq, Iran and Burma, and travel through Malaysia -- a transit point for many refugees headed for Australia.
The May agreement was an attempt to remove the incentive to sneak into Australia, Australian Prime Minister Julia Gillard said at the time.
"Under this arrangement, if someone seeks to come to Australia then they are at risk of going to Malaysia and going to the back of the queue -- that's what it means," she said.
In other words, those 800 who would have been transferred from Australia to Malaysia would not get preferential treatment over those refugees who were already there and had begun to apply for asylum in Australia.