The Court of Justice dismissed Slovakia and Hungary's challenges in their entirety on Wednesday, finding support for the contested decision in Article 78 (3) of the TFEU, short for Treaty on the Functioning of the European Union. "The mechanism actually contributes to enabling Greece and Italy to deal with the impact of the 2015 migration crisis and is proportionate." .
The European Council's decision in September 2015 provided for 120,000 people "in clear need of worldwide protection" to be relocated from Italy and Greece to other EU member states.
Just under 28,000 people have been relocated under the scheme, rather than the 160,000 asylum seekers envisaged when it was agreed in September 2015.
The EU Commission is pursuing an "infringement procedure" against Hungary, Poland and the Czech Republic for failing to accept refugees. The decision is also likely to be welcomed by other countries such as Greece and Sweden, where the sheer volume of new arrivals threatens to overwhelm the system.
The two countries defied an European Union plan to resettle 120,000 registered refugees across the 28 member states through a quota system.
If Hungary, Poland and the Czech Republic do not cooperate with the relocation scheme, they could be referred to the ECJ and face heavy fines.
Beata Szydlo, the Polish prime minister, said: 'We expected this decision.More news: Why BRICS meeting is significant for India and China on Doklam backdrop
"The Slovak appeal did not concern the fact of whether or not Slovakia must take in migrants, " Peter Susko said in commenting on the sentence to ANSA.
Hungary complained that it should not have faced a migrant-relocation quota since it was in an emergency situation already based on the continued trouble it saw at its border with Croatia.
It estimates that another 2,800 still need to be relocated from Greece, while Italy counts 7,200 who are eligible so far this year - of which only 4,000 have been registered for relocation.
"Today's ruling shows that no country can hide from their responsibilities to refugees", Iverna McGowan, Director of Amnesty's European Institutions Office, said in a statement.
Some 54,000 are now due to be taken from camps in Turkey, which lowers the total figure to be relocated from Greece and Italy.
To date, Slovakia has accepted only about a dozen.
The commission said on Wednesday that 27,695 asylum seekers have been relocated so far from Greece (19,244) and Italy (8,451).
Hungary accused the Luxembourg court of making an "outrageous and irresponsible" politically driven decision.