Hungary and Slovakia challenged the EU's decision to distribute asylum seekers across the union on a mandatory quota basis at the EU's top court on Wednesday (10 May). The quotas came in the wake of the massive influxes of migrants in 2015.

During a hearing at the Luxembourg-based European Court of Justice (ECJ), Hungary and Slovakia argued that the procedure that gave birth to the mandatory quota decision was unlawful.

Student or retired? Then this plan is for you.

Faced with massive arrivals in Italy and Greece, in September 2015 EU interior ministers decided to relocate 120,000 people to other member states - based on a mandatory quota system over a period of two years.

Reluctant states opposed to the idea of mandatory quotas - the Czech Republic, Hungary, Romania and Slovakia - were outvoted by the other member states in a qualified majority vote, which weighs up factors such as population size.

Hungary and Slovakia decided to challenged the decision in December 2015.

On Wednesday, the two countries argued that the legislative procedure was flawed and that the European Parliament should have been involved in what ought to have been a co-decision procedure. Poland was the only EU country in the courtroom whose representatives backed the two countries' position.

Hungary and Slovakia argued that the decision of the ministers was contrary to an earlier commitment made by EU leaders at the European Council.

The European Commission originally suggested at the time that Hungary should also be added as a front-line member state, along with Greece and Italy.

The EU executive had hoped to include Hungary, which has seen a massive number of people crossing the country on their way to Germany and Northern Europe, but Budapest rejected.

Hungary argued on Wednesday that the commission should have tabled a new proposal after the country had refused it, as it became clear that relocation would take place only from Greece and Italy.

The Council of the EU - backed by Germany, France, Sweden, Luxembourg, Belgium, Italy, Greece and the European Commission - argued however that the fundamental principle of EU solidarity was at stake.

The judges had a few questions, and quizzed Hungary on the aspect of solidarity. Hungary argued that there are other means of solidarity, not only distributing migrants, and said it had spent millions of euros on border protection.

Based on the 2015 decision, Hungary should have decided over 1,294 asylum cases from Greece and Italy, whereas Slovakia would have had to take in 802 people. However, Hungary and Slovakia refused to take in asylum seekers under the quota plan.

The court's advocate general, Yves Bot, will issue his legal opinion on 26 July - a non-binding statement on the court's ultimate ruling. The final decision can be expected before the end of the year.

None of the member states are keen on relocating asylum seekers, demonstrated by the fact that only around 18,000 people have moved from Greece and Italy in more than a year-and-a-half under the plan.

If the court rules against Slovakia and Hungary, it would increase the pressure on the two Central European countries to take people in, and could lead to more legal procedures and fines.

In the eventuality that the court decides that the quotas violate EU law, it would leave the bloc's migration policies in disarray.

Viktor Orban and Robert Fico, the Hungarian and Slovak prime ministers (respectively), have been portraying the majority vote over their countries as an example of Brussels forcing its will upon them.

Last year, Fico called the migrant quota system "politically dead".