The Slovenian parliament passed legislation early on Wednesday that will give the army more power to help police guarding the state border as thousands of migrants flood into the country from Croatia after Hungary sealed off its border.

The new legislation will enable the soldiers to control the border when there are no police present. The army began helping guard the border on Monday, but so far only when police were present.

More than 20,000 migrants have arrived in Slovenia since Saturday morning in order to pass through to Austria. At least 6,000 spent the last night in Slovenia which provided them with shelter in refugee centers.

"We will officially ask the EU ... for police back-up and for financial help," Prime Minister Miro Cerar told reporters before the vote in parliament.

Opposition parties said the government should follow Hungary and put up a fence on Slovenia's border with Croatia to prevent migrants entering the country.

An official from the interior ministry said the possibility "of safeguarding border crossings with physical obstacles" cannot be excluded if the flow of migrants escalates.

Attempts by Slovenia to stem the flow of migrants since Hungary sealed its border with Croatia on Friday have triggered a knock-on effect through the Balkans, with thousands held up at border crossings.

In the last two days Slovenia, which has two million citizens and is the smallest country on the Balkan migrant route, has deployed 140 soldiers to the border to assist the police.