Ljubljana (AFP) - Migrants hoping to trek from Greece towards northern Europe found their path blocked after a string of western Balkan nations slammed shut their borders, exacerbating a dire humanitarian situation on the Macedonian frontier.

Slovenia and Croatia, two of the countries along the route used by hundreds of thousands of people in recent months, barred entry to transiting migrants from midnight. Serbia indicated it would follow suit.

EU member Slovenia said it would make exceptions only for migrants wishing to claim asylum in the country or for those seeking entry "on humanitarian grounds and in accordance with the rules of the Schengen zone".

Prime Minister Miro Cerar said the move meant that "the (Balkan) route for illegal migrations no longer exists", while EU President Donald Tusk said on Twitter, "Irregular flows of migrants along Western Balkans route have come to an end".

"Not a question of unilateral actions but common EU28 decision... I thank Western Balkan countries for implementing part of EU's comprehensive strategy to deal with migration crisis," Tusk added.

As the 28-nation EU battles the worst migration crisis since World War II, the fresh measures ramped up the pressure on the bloc to seal a proposed deal with Turkey to ease the chaos.

- Hoping for a 'miracle' -

Austria's decision in February to cap the number of migrants passing through its territory had already led to a gradual tightening of borders through the western Balkans -- and a backlog in Greece.

"This is putting into effect what is correct, and that is the end of the 'waving through' (of migrants) which attracted so many migrants last year and was the wrong approach," Austrian Foreign Minister Sebastian Kurz said.

Authorities in Greece, the main entry point into the EU across the sea from Turkey, said Wednesday that nearly 36,000 migrants were now stranded there. Police said a further 4,000 were unaccounted for.

The UN refugee agency estimated Wednesday there were also as many as 2,000 migrants stuck in Serbia.

Story continues

There are fears that some will turn to people-smugglers and try their luck getting into Albania, and from there to Italy, or into Bulgaria.

Meanwhile, more than 14,000 mainly Syrian and Iraqi refugees have camped out on the Greece-Macedonia border crossing -- many of them for weeks -- at a squalid camp.

Macedonia has not let anyone enter since Monday.

"We are hoping a miracle will happen," said Ola, a 15-year-old from war-scarred Aleppo who has lived in a tent at Idomeni with her mother and two younger brothers for two weeks.

"We thought Germany wanted us. That's why we took the boat and came here."

Greek officials on Wednesday were trying to coax refugees to leave Idomeni for migrant centres elsewhere in the country. Many are reluctant to do so, however, fearing this would mean the end of their journey north.

- Merkel's open door -

More than a million people have crossed the Aegean Sea into Greece since the start of 2015, many from Syria, Afghanistan and Iraq and most aiming to reach wealthy Germany, Austria and Scandinavia.

This has caused deep divisions among EU members about how to deal with the crisis and put German Chancellor Angela Merkel under severe pressure domestically for her open-door asylum policy.

Speaking during a visit to Washington on Wednesday, Danish Foreign Minister Kristian Jensen said Merkel had underestimated how many people would arrive after "sending out invitations to refugees around the world".

But Merkel, heading for a bruising in regional German elections on Sunday, hopes that a controversial deal discussed with Turkey at an EU summit on Monday, and due to be finalised on March 17-18, will be the answer.

The accord would see Turkey, currently hosting 2.7 million refugees from the five-year-old Syrian civil war and the main springboard for migrants heading to the EU, take back all illegal migrants landing in Greece.

Ankara proposed an arrangement under which the EU would resettle one Syrian refugee from camps in Turkey in exchange for every Syrian that Turkey takes from Greece, in a bid to reduce the incentive for people to board boats for Europe.

In return though, Turkey wants six billion euros ($6.6 billion) in aid, visa-free access to Europe's passport-free Schengen zone and a speeding up of Ankara's efforts to join the EU -- demands that go too far for some.