Hungary shut down its border with Croatia to the free flow of migrants on Saturday, adding another hurdle in their frantic flight from wars and poverty in the Middle East, Africa and Asia toward what they hope is a better life in Western Europe.

The closure prompted Croatia to redirect thousands of people — including women and small children soaked in cold rain — further west toward its border with Slovenia, the small European Union-member state which has no capacity to process large numbers wishing to head toward Austria and Germany. This could leave thousands stranded in Croatia and further east and south in Serbia and Macedonia.

Several buses packed with migrants arrived in the Slovenian border town of Petisovci early Saturday from Croatia. Police spokeswoman Suzana Raus said that after processing, most of them will be transferred toward the Austrian border.

"We have been in cold since two in the morning in Serbia," said Omar Thaqfa, 33, from Mosul in Iraq. "We were sitting in the street. Very cold. Inshallah, I am going to Germany."

Slovenia has said it would beef up border controls and create entry points for migrants to manage the influx, but would keep accepting migrants as long as Austria and Germany kept their borders open. Croatia has said it will close its border with Serbia if Slovenia does the same with Croatia.

Migrants had been coming through Croatia to get to Hungary and then further west. But Hungary blocked that route after midnight when police in full gear pulled a barbed-wire fence over a passage on the border with Croatia where some 140,000 migrants have passed since mid-September.

Hungarian Foreign Minister Peter Szijjarto announced the decision to close the border after a meeting of the national security Cabinet on Friday.

"The Hungarian government has taken the steps ... to protect the internal European freedoms and the security of the citizens of Hungary and Europe," government spokesman Zoltan Kovacs said minutes after the shutdown.

Hungary decided to order the border clampdown after EU leaders who met Thursday in Brussels failed to agree on a plan backed by Hungary to send EU forces to block migrants from reaching Greece.

"We know that this is not the best, but only the second-best solution," Szijjarto said.

He said normal border checkpoints with Croatia would remain open, though inspections will be tightened. "We will introduce stricter controls to be able to block border crossings done illegally," Szijjarto said.

Although Croatia is also a member of the European Union, unlike Hungary it is not part of the Schengen zone of passport-free travel. Slovenia is in the Schengen zone.

Over 383,000 migrants fleeing war and poverty in the Middle East, Africa and Asia have entered Hungary this year, nearly all passing through on their way to Germany and other destinations further west in the EU. The country clamped down on its border with Serbia with a similar razor wire fence on Sept. 15 and since then migrants have been taking a detour through Croatia to reach Hungary.

"We have every hope that the introduction of the border closure (with Croatia) will have the same positive effects as what we experienced on the border with Serbia," said Gyorgy Bakondi, senior adviser to Hungarian Prime Minister Viktor Orban.

___

Associated Press reporters Pablo Gorondi in Budapest, Hungary, and Dusan Stojanovic and Jovana Gec in Belgrade, Serbia, contributed.