Ljubljana (AFP) - Slovenia on Thursday approved a bill allowing police to seal the border with Croatia to migrants in case of a new influx along the so-called Balkan route, sparking condemnation from rights groups.

Under the new legislation, Slovenian authorities can reject asylum seekers directly at the frontier with non-Schengen member Croatia if migrant numbers suddenly rise and "threaten public order and internal security".

The bill mirrors tough measures adopted over the past two years by neighbouring Hungary and Austria following the eruption in 2015 of Europe's worst migration crisis since World War II.

Centre-left Prime Minister Miro Cerar said it was an "extreme measure we have to prepare in case it's needed".

Hundreds of thousands of refugees, many fleeing war in Syria, risked their lives at sea and trekked up from Greece as they tried to reach western and northern Europe before the Balkan route was largely shut down last March.

Slovenia -- which controls 670 kilometres (417 miles) of the Schengen visa-free area's external border -- became a key transit country in late 2015 when Hungary closed its borders to asylum seekers.

The country of two million people currently hosts around 267 migrants, according to official figures.

Thursday's bill passed with 47 votes for and 18 against in the 90-seat parliament.

Should a new migration crisis occur, the government will ask lawmakers to trigger the amendment and shut the border for a minimum of six months.

But rights groups warned that the law risks stripping refugees of protections guaranteed under international and EU law, in what they said amounted to illegal pushbacks.

"The new law... is a serious backward step for human rights in Slovenia", Amnesty International said in a statement.

"By sealing its borders to desperate people and turning its back on its international obligations, Slovenia is treading the same unseemly path as its neighbours -- Hungary and Austria," Amnesty spokeswoman Jelena Sesar said.

The Council of Europe said Wednesday that the measures would "not only tarnish Slovenia's image as a country fully committed to human rights, but would also risk provoking a domino effect in the region".

The crisis has boosted populist fringe parties across Europe and pressured traditionally centrist governments to adopt a much firmer stance on migrants.