Hungary's government plans to hold refugees and asylum seekers in border camps built with shipping containers, completely restricting their freedom of movement.

The measure will also apply to people in already existing facilities, who will be moved to the camps and kept there until their asylum claims are processed.

Prime Minister Viktor Orban's right-wing government said it had taken the tough new measure to deal with the thousands of people who have fled to Europe in the past two years. Orban's chief of staff described it as a protective measure.

"We need a legal system that protects us. This is a very serious change," Janos Lazar, head of the prime minister's office, said, adding that the measure would be enacted only when the government was in a state of emergency over migration. The government has declared the country to be in such a state since March of last year.

"Containers suitable for accommodating 200-300 people will be erected. Migrants will have to wait there for a legally binding decision on their claims," Lazar said.

Asylum seekers will be able to take part in court proceedings via telecommunications equipment that will be provided in the camps, he added.

IN PICTURES: Dark and smoky shelters for refugees stranded in Serbia

Lazar also said Hungary was ready to build a second, stronger fence on its southern border with Serbia and Croatia, and that the government was prepared to increase aid to charities working on the border.

Hungary built a previous border fence in September 2015 and introduced legislation making it a crime to climb or damage it. According to police, more than 2,200 arrests were made on the border between March 1 and March 22 of last year.

The border camp plan is part of a package of proposals to go before parliament, including one that would reintroduce automatic detention for asylum seekers, a measure suspended in 2013 after pressure from human rights groups.

Familes and children detained

Orban - who professes to be an admirer of US President Donald Trump - said last month that automatic detention was needed again in response to "terror" attacks in Europe, citing the November 2015 attacks in Paris.

Hungary's immigration policies have been roundly condemned by rights groups and refugee advocates, who say large numbers of people were already being held in closed camps.

"Automatic detention of all asylum seekers from the start until the end of the asylum procedure is a flagrant and clear breach of EU law and human rights standards," the Hungarian Helsinki Committee, a Budapest-based refugee rights group, told the AFP news agency, vowing to sue Hungary at the European Court of Justice in every case where refugees were illegally kept in custody.

"In addition, the indefinite detention of many vulnerable migrants, including families with small children, is cruel and inhuman."

OPINION: Another incurable, ugly disease - Far-right populism

Hungary is also building four small military bases along the border to house some 3,000 soldiers who now patrol it alongside police. The barracks are also being built with shipping containers.

Orban said he was aware his plans went against the policies of the European Union, of which Hungary is a member, putting the country in "open conflict" with the 28-nation bloc.

In October last year, the majority of Hungarians voted against an EU referendum aimed at sharing 160,000 refugees around the 28-member bloc through mandatory quotas.

Hungary has since not accepted any asylum seekers allocated under the scheme.

In 2016, Hungary granted asylum, or some form of protection, to 425 people out of 29,432 applications.