Hungarys parliament on Tuesday approved the automatic detention of all asylum-seekers in container camps at the countrys southern borders, brushing off concerns from rights groups.
The legislation, approved by a large majority of lawmakers, is in response to recent terror attacks in Europe carried out by migrants, according to hardline Prime Minister Viktor Orban.
There they will be prevented from moving around Hungary or leaving the country while their applications are processed, unless they are going back over the border to Serbia.
"In the future, illegal immigrants must wait for the verdict on their asylum case in designated transit zones at the border," read Tuesday's bill, published on the Hungarian parliament's website.
It reinstates Hungary's practice of detaining asylum applicants, which it suspended in 2013 under pressure from Brussels, the UN refugee agency and the European Court of Human Rights.
Amnesty International said in a statement last month that the new rules "disregard EU guiding principles that it is forbidden to detain someone on the basis that they have claimed asylum".
"Elderly, sick people as well as families with children may also be detained (in the containers)," the rights group said.
'Poison'
The bill is the latest element of a tough anti-immigration stance by Orban -- who has called immigration "poison" -- which has long been slammed by rights groups as inhumane.
As well as building militarised razor wire fences on its borders with Serbia and Croatia in 2015, Hungary has handed thousands of migrants expulsion orders for "illegal border-crossing" and even jailed some.
It has also gradually been closing down its network of refugee camps, while allowing only a trickle of asylum-seekers into the existing transit zones.
According to the government, 1,004 people have applied for asylum in Hungary so far this year.
According to government officials, the new border camps will comprise converted shipping containers built onto existing "transit zones" erected in 2015 at the southern border with Serbia.
The government says the new legislation will protect both Hungarian and EU citizens.
It says migrants have been abusing the previous rules and leaving Hungary before a verdict is reached, exposing the bloc to the risk of terror attacks.
"Any legal regulation that facilitates terror acts must be changed in the interests of our own self-defence," Orban said in January.
The 53-year-old Orban, a strong admirer of US President Donald Trump, has long taken a hard line on immigration.
He has said that a large influx of Muslim migrants into Europe poses a security risk and endangers the continent's Christian culture and identity.
Budapest has refused to take part in an EU scheme to share around the EU the hundreds of thousands of migrants who entered the bloc in recent years.
Another change in law last year enabled police to physically push back to Serbia anyone caught in Hungarian territory within eight kilometres (five miles) of the border.
The interior ministry was forced Monday to defend police against accusations of brutality against migrants, made in a newspaper article by medical aid organisation Doctors Without Borders (MSF).
The ministry "repeatedly and categorically rejects the unverified allegations," said a statement.