The Slovenian parliament has passed legislation that gives the army more power to help stem a refugee influx that increased drastically since neighbouring Hungary sealed off its border last week.
Parliament members voted 66-5 early on Wednesday to allow the troops to warn, direct and temporarily restrict the movement of persons or engage in crowd control, as police normally do.
The law envisages that the new measures can put in force in an exceptional situation and for three months with the possibility to extend the period.
Slovenian soldiers have already been deployed to help control the border.
More than 20,000 refugees have arrived in Slovenia since Saturday morning in order to pass through to Western European countries. At least 6,000 spent the last night in Slovenia which provided them with shelter in refugee centres.
Prime Minister Miro Cerar told reporters before the vote in parliament that the government will "ask the EU for police back-up and for financial help" to deal with the refugee crisis.
Opposition parties said the government should follow Hungary and put up a fence on Slovenia's border with Croatia to prevent refugees 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 refugees 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 stranded at border crossings.
At least 12,100 refugees were currently in Serbia, the prime minister said on Tuesday. About 6,000 migrants had entered Austria from Slovenia on Tuesday, a police spokesman in Styria province said.
Related: Can the flow of refugees into Europe be stopped?
In the last two days Slovenia, which has two million citizens and is the smallest country on the Balkan route, has deployed 140 soldiers to the border to assist the police.
Over half a million refugees and migrants have arrived by sea in Greece this year and the rate of arrivals is rising in a rush to beat the onset of freezing winter, the United Nations said.
The vaste majority will head to Macedonia and then cross to Serbia looking to reach Western Europe via Croatia and Slovenia, avoiding the previous route through Hungary.