LUXEMBOURG (Reuters) - Hungary and Slovakia told the European Union’s top court on Wednesday that sharing out asylum-seekers among member states under a quota system was unlawful, clashing with Germany, France and others in a dispute that threatens to tear the bloc apart.

FILE PHOTO: Migrants from Afghanistan hold hands as they walk along the Serbian-Hungarian border fence at a makeshift camp near the village of Horgos, Serbia, June 14, 2016. REUTERS/Marko Djurica/File Photo

Some 1.6 million migrants and refugees have crossed the Mediterranean and entered the EU since in 2014, mostly fleeing conflicts or poverty in the Middle East and Africa.

The EU proposed in 2015 redistributing just 120,000 of them to help relieve pressure on frontline states Italy and Greece but ran into fierce resistance from ex-communist countries.

During a hearing at the EU’s Luxembourg-based Court of Justice, Hungary and Slovakia defended their refusal to take in asylum seekers, drawing a clear rebuke from Germany and others who stressed the need for European solidarity.

“One of the main arguments is the incorrect legal basis,” said Krisztian Kecsmar, a Hungarian justice ministry official. “It is a matter of institutional equilibrium, what role the institutions play in decision-making.”

The leaders of Hungary and Slovakia, Viktor Orban and Robert Fico, have sought to cast the quota system - agreed by EU in a majority vote against the will of four eastern states - as an example of heavy-handed rule by remote bureaucrats in Brussels.

Poland’s previous, pro-EU government reluctantly voted in 2015 for the quotas, which are based on a country’s population and wealth, but it has since been replaced by a more euroskeptic administration which has also refused to implement the decision.

On Wednesday, Poland was the only EU state in the courtroom to back Slovakia and Hungary. A Polish envoy said accepting migrants and refugees could pose a threat to national security.

SOLIDARITY

Ranged against the easterners in court were Germany, France, Sweden, Luxembourg, Belgium, Italy, Greece and the EU’s executive European Commission, which argued that the fundamental principle of EU solidarity was at stake in the case.

“The answer you will give to this question will have significance that goes way beyond this case,” German representative Ralf Kanitz told the court.

Germany, which faces an election in September, took in the bulk of asylum-seekers in 2015 and 2016, in stark contrast to Poland and Hungary, which refuse to host a single person under the EU’s programs to move a total of 160,000 people.

Many other EU states have also dragged their feet and only some 18,000 people have moved from Greece and Italy in more than a year-and-a-half under the plan, which expires in September.

Germany and other net contributors to the EU budget are increasingly upset that the easterners are failing to help out even as they benefit from the bloc’s generous development funds.

The tribunal’s advocate general will present on July 26 an opinion on the case, which may be indicative of the ruling that is expected this autumn.

If the court rules against Slovakia and Hungary, it would give Brussels and other EU states more arguments to pressure the easterners to take in asylum-seekers, and could also lead to more legal wrangling and fines.

If the court decides that the quotas violate EU law, it would leave the bloc’s migration policies in even greater disarray at a delicate time when it already struggles with other major challenges such as Britain’s exit and economic woes.

Apart from migration, the right-wing governments in Hungary and Poland have also clashed with the EU over democratic standards, judicial independence and media freedom.