Migrants make their way on foot on the outskirts of Brezice, Slovenia October 20, 2015. REUTERS/Srdjan Zivulovic

LJUBLJANA (Reuters) - Slovenia’s parliament amended its laws on Thursday to enable police to seal the country’s borders to most illegal migrants for a limited period if this is deemed necessary for reasons of national security.

The amendments were passed by 47 votes to 18 although several humanitarian organizations said they might amount to a violation of human rights.

“Slovenia cannot wait until public order and internal security are in danger,” Interior Minister Vesna Gyorkos Znidar told parliament before the vote.

“If the European Union will not find a sustainable and effective solution (to the migration problem), Slovenia has a legitimate right and obligation to use decrees that are necessary to protect its interests,” she added.

The Amnesty International said earlier on Thursday the new law “is a serious backward step for human rights in Slovenia”.

The Council of Europe, the continent’s leading human rights organization, called upon parliament last week to reject the amendments, saying states should ensure that migrants arriving at their borders have access to a procedure enabling them to put forward reasons not to be refused entry.

But Slovenia claims it has to prevent a repeat of a six-month-influx of migrants that ended in March 2016, when several countries to its south closed the main Balkan migrant route.

In that period Slovenia, the smallest state along the migration corridor, saw almost 500,000 illegal migrants crossing the country on their way to wealthier west European countries.

Centre-left Prime Minister Miro Cerar had said Slovenia would not be able to endure another large influx of migrants, particularly since its northern neighbor Austria and other west European states were closing their doors to migrants.