Hungary has closed its border with Croatia in an effort to stem the flow of migrants through the country en route to western Europe.
Croatia said it would begin directing migrants to Slovenia instead.
Hungary has been a major transit country for migrants, many of whom aim to continue on to Austria and Germany.
It announced the closure on Friday after EU leaders failed to agree a plan backed by Hungary to send a force to prevent migrants reaching Greece.
The border, reinforced with a razor-wire fence, closed at midnight (22:00 GMT) on Friday.
A group of 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," Hungarian Foreign Minister Peter Szijjarto said, announcing the closure earlier. 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.
Hungary has already sealed its border with Serbia.
There are fears in Slovenia that closure of the Croatia-Hungary border will channel many more migrants through Slovenia.
Early on Saturday, migrants began arriving in Slovenia by bus from Croatia, news agencies reported.
Ranko Ostojic, Croatia's Interior Minister, said Croatia was "turning the route, the corridor, towards Slovenia".
Croatia has not struck any agreement with Slovenia, according to Mr Ostojic. "This is (purely) a Croatian plan," he said.
In response, Slovenia stopped all passenger rail transport from Croatia, the country's national railway company announced.
Slovenia's Interior Minister, Vesna Gjorkos Znidar, said extra police had been deployed to the border with Croatia.
But she said the country will keep accepting refugees as long as neighbouring Austria and Germany keep their borders open.
Earlier on Friday, Turkish officials stressed that a plan agreed by EU officials for joint action with Turkey on the migrant crisis had not been finalised.
EU leaders have agreed to speed up visa liberalisation talks for Turks if Turkey stems the influx, as well as to "re-energise" talks on Turkey joining the EU and supply more aid.
German Chancellor Angela Merkel said EU states were considering a Turkish request for €3bn (£2.2bn, $3.4bn) in aid.
But Turkish President Recep Tayyip Erdogan has heavily criticised Europe's reaction to the migrant crisis.
"They announce they'll take in 30,000 to 40,000 refugees and then they are nominated for the Nobel for that. We are hosting two-and-a-half million refugees but nobody cares," he said.
Nearly 600,000 migrants have reached the EU by sea so far this year, many of them travelling from Turkey.
Can deeds match words?: The challenges ahead for the EU and Turkey
The pull of Europe: Five migrant stories
Merkel under pressure: Chancellor's migrant policy faces criticism at home
Focus on Turkey: Why the EU views Syria's northern neighbour as key
Crisis in graphics: Migration numbers explained
Ms Merkel is due to travel to Turkey at the weekend. "There is still a huge amount to do," she said, "but you cannot say that we've achieved nothing."
EU sources had said several countries were cautious about coming to an agreement with Turkey too quickly, including Greece, Cyprus and France.
Have you been affected by the migration crisis? You can email firstname.lastname@example.org with your experiences.
Please include a contact number if you are willing to speak to a BBC journalist. You can also contact us in the following ways: