BUDAPEST, Hungary (AP) — The European Union's top court on Wednesday rejected legal action by Hungary and Slovakia seeking to avoid accepting refugees under an EU-wide plan, a decision seen as a victory for those countries bearing the greatest burden of Europe's migrant influx.
In a long-awaited test case, the European Court of Justice said it had "dismissed in its entirety the actions brought by Slovakia and Hungary."
Hungary branded the ruling "outrageous and irresponsible," while Slovakia said it would accept the verdict even if it still opposes legally-binding EU refugee quotas.
Human rights group Amnesty International welcomed the ruling, saying Hungary and Slovakia had been trying to turn their countries into "refugee-free zones."
Greece and Italy have been on the front line of the torrent of migrants and refugees flooding into Europe in the last few years, as hundreds of thousands of people from war zones like Syria and Iraq or job-seekers mostly from Africa have arrived on their shores.
EU nations agreed in September 2015 to relocate 160,000 refugees from Greece and Italy over two years, but only around 27,700 people have been moved so far, according to figures released Wednesday. Hungary and Slovakia were seeking to have the plan annulled.
Hungary and Poland have refused to take part altogether, while Slovakia has accepted only a handful of refugees from Greece.
The refugee sharing plan was adopted by a "qualified majority" EU vote — around two thirds of the bloc's members — and the court held that this was appropriate, saying the EU "was not required to act unanimously" on this decision.
The court noted the small number of relocations so far is due to factors that the EU could not have foreseen, including "the lack of cooperation on the part of certain member states."
Hungarian Foreign Minister Peter Szijjarto called the court ruling "outrageous and irresponsible."
"The decision puts at risk the security of all of Europe and the future of all of Europe as well," Szijjarto said, calling the ruling "contrary to the interests of the European nations, including Hungary."
Szijjarto said Hungary would focus on defending the EU's external border against incoming migrants and asylum-seekers and urged the EU to abandon its "unsuccessful" refugee-sharing plan.
"The real battle is only just beginning," Szijjarto said, vowing that Hungary would continue to challenge any EU attempt to resettle migrants in Hungary without its approval.
Slovakian Prime Minister Robert Fico said he respected the court decision, but that his government still does not like the relocation plan, which he and others in Eastern Europe see as quotas imposed on them by unelected EU bureaucrats in Brussels.
"We fully respect the verdict of the European Court of Justice," Fico told reporters, adding that his government's negative stance on the relocation plan "has not changed at all."
Fico said the scheme was a temporary solution that will end on Sept. 26. He says he believes his country doesn't face any sanctions from the EU over its stance. EU officials say countries will still have to share eligible asylum-seekers arriving in Greece and Italy up until Sept. 26.
Despite the court ruling, Polish Prime Minister Beata Szydlo said her country will stick by its refusal to take in refugees.
"This absolutely does not change the position of the Polish government with respect to migration policy," she said.
Welcoming the court verdict, EU Migration Commissioner Dimitris Avramopoulos warned Hungary, the Czech Republic and Poland that they could face legal action if they don't live up to their refugee obligations "in coming weeks."
Slovakia is not included in the legal action as it recently agreed to host a few refugees.
The European Commission has already launched an "infringement procedure" against the three nations for failing to take, or not recently accepting, refugees who have arrived in Italy and Greece in the last two years.
Avramopoulos said if they fail to act soon, the Commission should consider taking "the last step in the infringement procedure, to refer Poland, Hungary and the Czech Republic to the European Court of Justice."
German Foreign Minister Sigmar Gabriel said he expects all EU countries to implement the decision "without further hesitation."
"Solidarity is not a one-way street," he said.
The Hungarian Helsinki Committee, an advocate for asylum-seekers, urged Hungary to give refugees an opportunity to make their case for asylum.
"The lesson of the verdict is that helping people fleeing war and terror is truly a common responsibility for Europe," the group said. "Hungary needs to respect the decision of the EU court."
Hungarian Prime Minister Viktor Orban's government has made migrants a key political issue since early 2015 and ahead of the parliamentary election expected in April 2018.
Hungary's position is that only its elected leaders should be able to decide who is allowed into the country. Orban has said the large influx of mainly Muslim immigrants threatens Europe's and Hungary's cultural identity.
In mid-September 2015, Hungary closed off its southern border first with Serbia and later with Croatia with a fence protected by razor wire. The fences have mostly stopped migrants from passing through Hungary on their way to Western Europe but Hungary has also greatly reduced the chances for asylum-seekers to submit applications in the country.
In other news, the EU said the bloc's migrant agreement with Turkey was working well but that more effort was needed to speed asylum applications.
"The EU-Turkey statement continues to work and deliver results," Avramopoulos said, adding that migrant arrivals in Greece from Turkey had dropped 97 percent since the deal began in March 2016.
Cook reported from Brussels.