The European Court of Human Rights has fined Belgium and Greece over their treatment of an Afghan asylum seeker, saying his rights were violated.
The ruling challenges the Dublin II Regulation, used by many EU countries to send asylum seekers back to Greece, despite the country's backlog of cases.
Belgium sent the Afghan man, identified only as "MSS", back to Greece because it was his entry point into the EU.
But he ended up homeless, struggling in dire poverty in 2009.
This week Germany became the latest European country to halt the practice of sending asylum seekers back to Greece. The UK, Sweden, Norway and Iceland have also stopped doing so because of the poor conditions that many migrants face in Greece.
The court in Strasbourg ordered Belgium to pay MSS 32,250 euros (£27,227; $43,408) in damages and costs, and Greece to pay him 5,725 euros. The judgement by the court's grand chamber is binding and cannot be appealed.
Life on the streets
Greece will also have to deal with his asylum claim without delay, in full accordance with the European Convention on Human Rights, the judges said.
MSS left Kabul in early 2008 and travelled to Belgium via Greece. He had earlier passed through Iran and Turkey.
Claiming asylum in Belgium, he said he had survived a murder attempt by the Taliban - allegedly a reprisal for his having worked as an interpreter for the US-led forces.
In June 2009 he was sent back to Greece, despite having told the Belgian authorities that he risked detention in appalling conditions there.
He had also expressed fear that his case would not be examined properly and that he could be sent back to Afghanistan.
"In spite of the obligations incumbent on the Greek authorities... he spent months living in extreme poverty, unable to cater for his most basic needs - food, hygiene and a place to live - while in fear of being attacked and robbed," the ruling said on Friday.
Greece has become the major entry point into the EU for illegal migrants and the UN refugee agency, UNHCR, has complained that Greek reception centres are inadequate.
Greece has announced plans to build a 12km (eight-mile) fence along part of its border with Turkey to keep illegal migrants out.