Migrants have begun arriving in Slovenia by bus from Croatia, after Hungary shut its border with Croatia to try to stem the numbers arriving en route to Western Europe.
Hungary closed its Croatia frontier on Friday and now says it will reintroduce controls on its Slovenia border.
Many of the migrants aim to continue north to Austria and Germany.
Nearly 600,000 migrants have reached the EU by sea so far this year, many travelling from Turkey to Greece.
However more than 3,000 have perished trying to cross the Mediterranean. Many migrants are Syrians fleeing the civil conflict there.
Hungary said it shut the border with Croatia after European Union leaders failed to agree its plan to send a force to prevent migrants reaching Greece.
Hungary’s closure of its border with Croatia comes just a month after it shut its frontier with Serbia, which was another transit route to Western Europe.
Foreign Minister Peter Szijjarto said border controls with Slovenia would be temporarily reinstated to safeguard Hungary from a “mass wave of unidentified, uncontrolled migrants.”
Hungary and Slovenia are both part of the passport-free Schengen zone, but Croatia is not.
Until Friday night, 5,000 to 8,000 people were being allowed across Hungary every day, without registration, bound for Austria.
There are fears in Slovenia, a nation of some two million people, that the latest border closure will channel many more migrants through the country.
Extra police had been deployed to the border with Croatia, Slovene Interior Minister Vesna Gjorkos Znidar said.
But the country will keep accepting refugees as long as Austria and Germany’s borders remain open, she said.
Slovenia’s national security council is due to meet on Saturday.
All passenger rail transport from Croatia has already been stopped.
Those arriving by road will be transferred to a migrant centre near the Austrian border after a registration procedure, AP quoted police spokeswoman Suzana Raus as saying.
The past month has seen some 3,000 migrants pass through Slovenia, Reuters news agency reported. Slovenia has said it was in a position to accommodate up to 8,000 migrants per day.
Late on Friday, several hundred migrants who arrived near the village of Zakany minutes before the deadline were the last to be allowed through.
“Closure!” a soldier shouted after the last travellers had passed across.
“We know that this is not the best, but only the second-best solution,” Foreign Minister Szjjarto said on Friday when announcing the closure. Migrants could still apply for asylum in Hungary at two border transit zones, he added.
The border posts at Beremend and Letenje are also open for anyone with valid documents.
Croatia’s Interior Minister, Ranko Ostojic, said his country was “turning the route, the corridor, towards Slovenia”.
But it had not struck any agreement with Slovenia, according to Mr Ostojic. “This is (purely) a Croatian plan.”
BBC Balkans correspondent Guy de Launay says this plan will only work as long as Slovenia allows refugees to enter.
If Slovenia did completely shut its borders, then Croatia would be faced with an influx of around 5,000 refugees a day – and nowhere to send them, our correspondent says.