BRUSSELS (Reuters) - The European Union’s top court ruled on Thursday that Poland, Hungary and the Czech Republic had broken the law by refusing to host refugees to help ease the burden on southern states such as Greece and Italy after a surge in migrant arrivals from 2015.

The ruling underscores Europe’s bitter divisions over migration, though the three ex-communist nations face no immediate penalty as the relocation of tens of thousands of people agreed by the EU was only envisaged until 2017.

“By refusing to comply with the temporary mechanism for the relocation of applicants for international protection, Poland, Hungary and the Czech Republic have failed to fulfil their obligations under European Union law,” the Luxembourg-based Court of Justice of the European Union said in its ruling.

The eurosceptic, nationalist governments on the EU’s eastern flank had cited national security reasons in refusing to take in any of the mostly Muslim refugees and migrants who had fled wars and poverty in the Middle East, North Africa and beyond.

Frontline states such as Italy and Greece complained angrily over the lack of European solidarity as they struggled with mass arrivals that overwhelmed their security and welfare systems.

Slideshow ( 3 images )

Wealthy northern European states such as Germany also criticised the ex-communist east for refusing to help while continuing to benefit from generous EU financial aid.

More than a million people reached Europe’s shores from across the Mediterranean in 2015, catching the EU unprepared as they trekked across the continent and triggering a new wave of support in some quarters for far-right, anti-immigrant parties.

The EU has since cracked down on immigration, fortifying its external borders and offering money and aid to countries such as Turkey to help prevent migrants from heading to Europe.

But the internal EU divisions on migration are far from healed. The 2015 mass influx of migrants at least partly contributed to Britain’s 2016 decision to leave the EU, in the worst setback for European integration since World War Two.

The EU now faces a fresh test of its unity from the coronavirus pandemic, with member states mostly pursuing their own strategies to counter the spread of the disease and the worst affected nations - Italy and Spain - again complaining of a lack of European solidarity and aid.