Poland, Hungary and the Czech Republic broke European law when they failed to give refuge to asylum seekers arriving in southern Europe, often having fled war in Syria and Iraq, the EU’s top court has ruled.

The three central European countries now face possible fines for refusing to take a share of refugees, after EU leaders forced through mandatory quotas to relocate up to 160,000 asylum seekers at the height of the 2015 migration crisis.

Issuing its judgment on Thursday, the European court of justice said the three member states “had failed to fulfil their obligations under European Union law”. The Czech Republic took in just 12 asylum seekers, while Hungary and Poland refused to take a single person.

The court rejected the legal argument that Hungary, Poland and the Czech Republic were entitled to disregard EU law in order to maintain public safety, law and order. None of the countries had proved it was necessary to invoke that opt-out clause in the EU treaties, the court concluded.

The European commission is now entitled to embark on legal action to impose fines on the three member states.

The decision to impose mandatory quotas of asylum seekers was taken in the teeth of fierce opposition from Hungary and the Czech Republic. After the nationalist Law and Justice party was elected in October 2015, Poland joined its neighbours in opposing the scheme.

The quotas have come to be seen as one of the modern EU’s defining moments, which poisoned relations between central Europe and western member states, leaving divisions that continue to thwart a common EU asylum policy.

The previous head of the European council, Donald Tusk, said the scheme had been “divisive and ineffective”, but countries, such as Germany and Sweden, which took in large numbers of refugees, have argued it is unacceptable for member states to shirk the task of easing the strain on the most-affected EU countries.

In September 2015, EU leaders took two decisions to relocate 40,000, then 120,000 asylum seekers from Greece and Italy to other EU countries. More than 1 million migrants and refugees arrived on Europe’s shores in 2015, triggering a political crisis that continues to haunt the union.

When the scheme closed, only 34,712 people had been relocated: 21,999 from Greece and 12,713 from Italy. The European commission claimed that the EU’s deal with Turkey meant the original number of places were no longer needed, because migrant arrivals fell sharply from March 2016.

The UN refugee agency reported last month that more than 36,000 asylum seekers were living in desperate conditions on five Greek islands in squalid camps originally designed for 5,400 people.

Greece’s minister for migration, Notis Mitarachi, told members of the European parliament’s home affairs committee on Thursday that 20 asylum seekers living at a camp near Athens had been confirmed as having coronavirus.

He said no cases had been confirmed on the Greek islands and urged other EU countries to take in people on the islands.

Responding to widespread concern about filthy camp conditions, he said: “Some have argued to transfer people to the mainland – that is from non-infected areas to infected areas – but we do not have empty spaces to do that. We will require additional funding for additional spaces, but these spaces cannot be ready within a few days.

“We will strongly welcome any offers of relocation from member states that have capacity because we cannot resolve this crisis instantly and alone.”

The EU home affairs commissioner, Ylva Johansson, told MEPs that some unaccompanied children on the islands would be relocated from next week. Eight EU countries have volunteered to take in 1,600 lone children.