Hungary closed its border with Croatia at midnight (2200 GMT) Friday to contain the flow of thousands of migrants arriving daily in the country, before traveling to northern Europe.
A final group of several hundred migrants was permitted to cross the border shortly before it was sealed off at midnight local time. A fence along the frontier has already been built to prevent unauthorized crossings.
Hungarian Foreign Minister Peter Szijjarto announced the decision to seal the border after a meeting of the national security cabinet earlier Friday.
He said that Budapest had informed its border countries and beyond about its decision. Hungary sealed the border with Serbia in September with fences.
In response to the Hungarian move, Slovenia announced Friday that it is suspending all train services to Croatia. The flow of people is expected to shift to Slovenia when Hungary closes its border with Croatia for migrants.
Slovenia said it would continue to accept the migrants but wants to control the influx. Instead of transporting the new arrivals to its borders, the trains will deliver them to refugee centers.
More than 380,000 migrants have entered Hungary in 2015 and Hungarian authorities anticipate the number to exceed 700,000 by the end of the year.
Nearly 600,000 migrants have reached the EU by sea, many of them travelling from Turkey to Greece before seeking to head north.