The Hungarian parliament approved legislation Tuesday authorizing the government to detain asylum seekers in container camps along the country’s border.

Migrants will be detained indefinitely until their asylum applications are processed. They have the option to leave for their home countries at any point.

Prime Minister Viktor Orban said the measures are a response to recent terror attacks across Europe.

“The migration flow has only slowed, but it is not over,” Orban said at a swearing-in ceremony for hundreds of border guards, according to BBC. “We have gained time to strengthen our lines of defense.”

Orban called immigration the “the Trojan horse of terrorism.” He hopes the threat of detention will deter migrants from going to Hungary in the future.

“Those readying for the journey do not want to live according to our ways and culture, but according to their own – only with a European quality of life,” Orban said.

The EU directive on the treatment of asylum-seekers states that detention can only be allowed under “clearly defined exceptional circumstances.” Hungary hopes the option to give up on asylum and return home is enough to convince EU lawyers that the legislation doesn’t include involuntary detention.

Amnesty International described the measures as a “flagrant violation of international law.”

“Rounding up all men, women and children seeking asylum and detaining them months on end in container camps is a new low in Hungary’s race to the bottom on asylum seekers and refugees,” Gauri van Gulik, Amnesty’s deputy director for Europe, said in a statement.

Follow Jacob on Twitter

Content created by The Daily Caller News Foundation is available without charge to any eligible news publisher that can provide a large audience. For licensing opportunities of our original content, please contact licensing@dailycallernewsfoundation.org.