March 7 (UPI) -- The United Nations' global refugee agency on Tuesday condemned as illegal a new Hungarian law to round up asylum seekers and hold them at containment camps near its borders.
The Office of the U.N. High Commissioner for Refugees renounced the plan after Hungary's parliament passed the legislation -- a measure officials say is a safeguard against potential terrorist attacks.
Hungarian Prime Minister Viktor Orban said the law is a security response to recent European attacks that were perpetrated by insurgents posing as political refugees.
"The migration flow has only slowed, but it is not over," he said at a swearing-in ceremony for hundreds of new border guards. "We have gained time to strengthen our lines of defense."
Orban said Hungary is "under siege" and that insurgents are using political migration as a "Trojan horse for terrorism."
Although it was fiercely criticized after its submission last month, the legislation won near-unanimous approval Tuesday by a vote of 138-6.
Budapest's new strategy to funnel refugees into border camps -- for the duration of their asylum process -- has elicited deep concern from various advocacy groups. The U.N. refugee agency said Tuesday Hungary's plan violates European law.
"The new law violates Hungary's obligations under international and European Union laws, and will have a terrible physical and psychological impact on women, children and men who had already greatly suffered," the UNHCR said in a statement.
"In practice, it means that every asylum seeker, including children, would be detained in shipping containers surrounded by high razor-wire fence at the border for extended periods of time."
The UNHCR said detaining refugees is only lawful on certain grounds and only in cases where it is "necessary, reasonable and proportionate." Further, the agency said, mass detention should only occur after all alternative measures are exhausted.
"Failure to do so could render detention arbitrary," the UNHCR said. "Children should never be detained under any conditions, as detention was never in a child's best interest."
"Dumping all refugees and migrants into containers isn't a refugee policy it's avoiding one," Amnesty International echoed, calling the measure a "flagrant violation" of international law.
Before the new law, refugees could be held for up to four weeks if they were detained within five miles of Hungarian borders. The new rules remove the time and location restrictions and places unaccompanied children under 14 into the care of Hungary's child protection services.
Hundreds of thousands of political refugees have sought asylum in several European countries over the past two years, the vast majority seeking to escape war and militant violence in their homelands. Some observers have noted that the mass influx of refugees has simultaneously made it easier for militants plotting violence to go undetected.
U.S. President Donald Trump controversially ordered in January that all foreign refugees, and immigrants from seven largely Muslim nations, be prohibited from entering the United States. Trump ultimately scrapped the order after it was blocked by American courts and replaced it Monday with a similar measure the White House believes is more legally sound.
"What was of concern to UNHCR was the level of anxiety of those who were about to be resettled, and now saw their lives on pause and were left wondering what would happen next," the agency said of the new Trump order.
"More generally, the International Organization for Migration was concerned that the bedrock of migration management, that it should be safe, orderly and secure ... should not be lost in a global climate which was increasingly xenophobic," the agency added. "Nation states had the absolute right to see to their security, but that should be done in a balanced way."