In a strongly worded ruling, the European Court of Justice said that the EU was within its rights to order members to take in refugees from Greece and Italy, where almost 200,000 asylum seekers, mainly from Syria, remain stranded amid a grinding migration crisis.
Slovakia and Hungary lost a challenge Wednesday to European Union regulations that would have them take in asylum seekers, taking the pressure off countries like Greece and Italy besieged by the 2015 migrant crisis.
"That mechanism actually contributes to enabling Greece and Italy to deal with the impact of the 2015 migration crisis and is proportionate", a news release on the ECJ's ruling said.
Slovakia and Hungary voted against the adoption of the contested decision in the council - as did the Czech Republic and Romania - and lobbied for annulment by the European Court of Justice.
German officials were also quick to announce their support for the ruling, with Sigmar Gabriel, the foreign minister, encouraging member states to act swiftly following the decision. 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.
Slovakia's Prime Minister Robert Fico said his country respected the court's judgement, adding, however, that its critical stance on the quota system and the migrants "has not changed at all".
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.
The UNHCR urged European Union nations to "increase the pace of relocation for eligible asylum-seekers from Italy and Greece, and to fully meet their relocation commitments as a concrete gesture of solidarity towards countries of first arrival in the EU".
According to the International Organization for Migration, as of August 30 this year, only 27,412 people had been relocated to 24 countries, compared with the 120,000 provided for by the scheme.
The EU has taken in more than 1.7 million people from the Middle East and Africa since 2014.
In Budapest, Hungarian Foreign Minister Peter Szijjarto called the court's decision "outrageous and irresponsible".
The European Court of Justice overruled Hungary and Slovakia's objections to the compulsory fixed-quota scheme.
"We will continue to work on having solidarity expressed in different ways other than forcing migrants [on Slovakia] from other countries that don't want to be here anyway".
He said the slow pace of relocation "draws attention to significant gaps in the EU's response to the biggest refugee crisis on the continent since World War II".
That reduction has helped ease the pressure on Italy and Greece, but political strains are still evident.
The court said Wednesday that it had "dismissed in its entirety the actions brought by Slovakia and Hungary".
"The real battle is only just beginning, and Hungary will be making use of all opportunities for legal redress to ensure that nobody can be relocated to Hungary against the wishes of the Hungarian people", Mr Szijjarto said.
The program is considered a key part of the EU's migration policy.