The European Court of Justice has dismissed a legal action by Hungary and Slovakia that challenged a European Union policy requiring them to accept refugees.

Hungarian Foreign Minister Peter Szijjarto said the ruling was "outrageous and irresponsible," the Associated Press reports, and vowed Hungary would fight any attempts to resettle migrants there without government approval.

At issue is a quota system adopted by the EU to help Italy and Greece amid the 2015 migration crisis. The European Council's decision in September 2015 provided for 120,000 people "in clear need of international protection" to be relocated from Italy and Greece to other EU member states.

Hungary and Slovakia asked the court to annul the decision.

"We fully respect the verdict of the European Court of Justice," Slovakian Prime Minister Robert Fico told outlets including the AP. But he said his government still is not happy with the relocation plan, which he and others from Eastern Europe see as being imposed on their countries by non-elected EU bureaucrats.

The EU Commission is pursuing an "infringement procedure" against Hungary, Poland and the Czech Republic for failing to accept refugees. Slovakia has recently agreed to accept a few refugees, so it's not included in that action.

Polish Prime Minister Beata Szydlo told the AP that though she was not surprised by the decision, it "absolutely does not change the position of the Polish government with respect to migration policy."

The EU's relocation plan — which expires on September 26 — has not been fully executed, in no small part because of some member states' reluctance to accept migrants.

As Deutsche Welle reports, "Only 24,000 ... refugees from Greece and Italy have been transferred to other states. ... Under the policy, Hungary is required to take in 1,294 refugees and Slovakia 902."

It's not clear what consequences there will be, if any, for member states that refuse to take in migrants.

"Given the tense politics of internal solidarity, it might make more sense for the commission to avoid insisting on the commitment, having made its point," Elizabeth Collett, the European director of the Migration Policy Institute, told The New York Times. "Few E.U. member states have actually met their relocation quota, and most were just a lot more passive about it."

Amnesty International welcomed the court's decision.

"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. "Slovakia and Hungary have tried to dodge the EU's system for solidarity, but each country has a role to play in protecting people fleeing violence and persecution."

The UN's migration agency reports that 125,860 migrants and refugees entered Europe by sea so far this year. That's less than half the number who arrived during the same time period last year. The agency estimated that 2,537 people have died in 2017 attempting to make the Mediterranean crossing.

In March 2016, the EU made a $7.1 billion deal with Turkey to have that country help alleviate the flow of migrants to EU nations, making Turkey essentially a refugee buffer zone, as NPR's Lauren Frayer reported at the time.

Copyright 2017 NPR. To see more, visit