Refugees seeking asylum in European countries must do so in the first country they reach, even in exceptional circumstances, the European Court of Justice ruled on Wednesday.

The case, which was brought by Austria and Slovenia, relates to migrants who arrived during the crisis of 2015-16, and could result in several hundred people being affected.

The European Union's top court upheld the Dublin Regulation, which states that refugees must seek asylum in the first place they reach.

Two Afghan families and a Syrian, who had first arrived in the EU via Croatia, had argued that they had exceptional circumstances for applying for asylum in neighbouring Slovenia.

The asylum seekers claimed that the 2015 migration crisis meant that the Dublin rule should be suspended in certain cases.

Austria and Slovenia had decided to send the asylum seekers back to Croatia after they had been sent to the border with Slovenia via bus by the Croatian authorities.

The court has now ruled that Croatia must decide on whether their application will be accepted and they can stay there, rather than the other states making the decision.

Critics of the Dublin rule, which is seen as an unfair burden on southern EU nations, where many migrants arrive first, had hoped the court might rule in favour of the asylum seekers' arguments.

In a statement announcing the decision, the court said: "A member state which has decided on humanitarian grounds to authorise the entry on its territory of a non-EU national who does not have a visa... cannot be absolved of that responsibility."

Austrian lawyer Clemens Lahner warned that hundreds in Croatia would feel the effect of the ECJ's decision.

He told the BBC: "For those already in Croatia - 700 or so - for them the story is over. Austria won't take them back."

In 2015, Germany temporarily suspended the EU's rule for Syrian refugees, forfeiting the country's right to send asylum seekers back to the first EU country they arrived in.

However, the decision was criticised by Germany's EU partners when many of the refugees ended up seeking asylum in neighbouring Austria.

Around 90,000 applied to stay in the German-speaking central European country, the equivalent of 1 per cent of its population.

The Dublin rule has been suspended in Greece, one of two main entry points for migrants from Africa and the Middle East since the crisis began in 2015.

However, the landmark ruling is set to have wider implications for Italy, the other main entry points for migrants, as it, unlike Greece, is still subject to the Dublin rule.

In this year alone 81,000 migrants have arrived in Italy, which is 14,000 more than in the same period in 2016.

Meanwhile, in a separate case on Wednesday the ECJ was advised to dismiss a challenge brought forward by Slovakia and Hungary opposing a 2015 European Council decision that countries must take in hundreds of asylum-seekers.

Advocate General Yves Bot rejected the challenge to the decision, which would see Hungary temporarily take in 1,294 asylum-seekers and Slovakia 902. The judgement by the Advocate General is often indicative of what the EJC's final ruling will be.

“The contested decision automatically helps to relieve the considerable pressure on the asylum systems of Italy and Greece following the migration crisis in the summer of 2015 and… is thus appropriate for attaining the objective which it pursues”, Bot explained.

The resettlement plan had been designed to deal with the crisis of 2015 and temporarily relocate 120,000 migrants.

However, as well as Hungary and Slovakia, it was unpopular in other EU member states with Poland and Romania voting against the relocation plan at the time.

A final ruling on the matter by the ECJ is expected to take place after the summer break.