The European Union warned the Czech Republic, Hungary and Poland on Tuesday that they have 24 hours to start taking in refugees under an EU migrant sharing plan or face legal action.

But the three countries immediately rebuffed the threat and appeared ready to go to court.

The European Commission said in a statement that it has repeatedly urged them to relocate refugees or at least pledge to do so under the legally-binding refugee plan agreed two years ago.

But it said they have failed to take action "in breach of their legal obligations," and that it "has decided to launch infringement procedures."

The plan to share 160,000 refugees in overwhelmed Italy and Greece among other European countries over two years was endorsed in September 2015 by a qualified majority vote.

It was seen as a major plank of the EU's migration policy, and was lauded as a pan-European show of solidarity in 2015 when more than a million people arrived in Europe seeking sanctuary or jobs.

But just three months before the September 2017 deadline, fewer than 21,000 people have been relocated. It's unlikely that even a quarter of the refugees originally foreseen under the plan will be moved by then.

The Czech Republic, Hungary, Romania and Slovakia voted against the scheme. Hungary and Slovakia had previously launched their own legal action against it.

EU Migration Commissioner Dimitris Avramopoulos said the Czech Republic, Hungary and Poland have until Wednesday to change their minds.

"There is still time ahead. Let's hope that not only reason but also the European spirit will prevail," Avramopoulos told reporters, lamenting that the three "have not done anything for more than one year."

But Czech Prime Minister Bohuslav Sobotka said his country is not ready to change its view of the migrant sharing plan.

Sobotka said in a statement that "the Czech Republic doesn't agree with the relocation system based on migrant quotas. And given the worsened security situation in Europe and also that the quota system is not functioning, it won't participate in it."

He said his government was ready to "defend our view at the EU level and at the relevant court institutions."

The Czech Republic was supposed to accept some 2,600 refugees but so far has taken only 12, all of them from Greece.

Polish Deputy Foreign Minister Konrad Szymanski said "Poland is ready to defend its standpoint before the Court of Justice."

He warned that the Commission's action "may deepen the divisions within the EU."

Hungarian Foreign Minister Peter Szijjarto said his government considers the infringement procedures to be "blackmail and un-European behavior."

Speaking in parliament ahead of the warning, Szijjarto repeated the government position that even the European Commission cannot take away the member states' right to decide who it wants to let into their country.

The executive Commission is watchdog over the EU's treaties and enforces agreements made between the 28 member states.

Avramopoulos praised Austria and Slovakia for recently pledging to do more. But as of June 9, Austria had still not relocated a single refugee. Slovakia had taken in 16.

Germany, France, the Netherlands and Finland have so far been the countries taking in the largest number of refugees — Germany received more than 5,600, France around 3,500.

Rights group Amnesty International said it hopes the Commission action will spur others to do more.

Amnesty's European office director Iverna McGowan said the move "makes it clear that countries will not be allowed to get away with dragging their feet to avoid accepting refugees. Solidarity is the key to a fair and humane response to refugees in Europe."