Laszlo Balogh/Reuters A mother breastfeeds her baby in front of piles of rubbish at a migrant collection point in Roszke, Hungary on Sept. 11, 2015.

Hungary will soon submit controversial plans to automatically detain asylum seekers to the European Union.

Chief government spokesman Zoltán Kovács said the detention plans, which defy EU immigration directives, are backed by “a change of mood in Europe” that was strengthened by the election of U.S. President Donald Trump.

“A change of perspective in the U.S. helped others to respect the Hungarian position,” said Kovács, speaking on behalf of the Hungarian prime minister. “We respect the USA’s sanctions,” he added, refusing to criticize Trump’s internationally condemned Muslim travel ban, now blocked in court. “The world is moving to a pragmatic era and we believe that the new U.S. government’s approach will ease the tension.”

All newcomers requesting asylum through Hungary will be confined to “shelters” for the duration of their application process, which Kovács said would likely take many months. Applicants can return to where they came from at any time, Kovács said Monday.

“No migrants ― not even those who have already issued their request for asylum ― will be able move freely until there is a primary legal decision whether they are entitled for political asylum, refugee status or anything else, so they are not entitled to move freely in the country,” Kovács said.

Currently, asylum seekers in Hungary can move throughout the country while awaiting a decision. In other European countries, like Belgium and Greece, asylum seekers are detained temporarily upon arrival.

The EU stipulates that “a person should not be held in detention for the sole reason that he or she is seeking international protection,” and an asylum seeker may only be detained under “exceptional circumstances.”

PETER MUHLY via Getty Images Prime Minister Viktor Orbán has described asylum seekers in Europe as "poison."

Hungarian Prime Minister Viktor Orbán is the first European leader to openly express support for Trump.

Like Trump, who plans to build a multibillion dollar wall along the U.S.-Mexico border, Orbán has fielded heavy criticism over his strict immigration stance. The populist leader praised Trump’s foreign policy as “vital” for Hungary, and celebrated Trump’s election victory as the end of “liberal non-democracy.”

The two leaders hold similar views on immigrants and refugees. Just a month after Trump called Syrian refugees America’s “Trojan horse,” Orbán described asylum seekers in Europe as “poison.” The prime minister said diplomatic ties between Hungary and the U.S. could greatly improve under Trump’s leadership.

Bloomberg via Getty Images Hungary erected fences along its Serbian, Croatian and Slovenian borders to divert illegal immigrants in 2015

Anti-immigrant sentiment has been well-documented in Hungary. Just two weeks after Trump signed an executive order banning travel to the U.S. from seven Muslim-majority nations, the mayor of a Hungarian village openly expressed his desire to ban Muslims from his community. In an interview with the BBC on Tuesday, Laszlo Toroczkai said: “We primarily welcome people from Western Europe ― people who wouldn’t like to live in a multicultural society. ... We wouldn’t like to attract Muslims to the village.”

Hungary built razor-wire fences along its borders with Serbia, Croatia and Slovenia to divert undocumented immigrants in 2015. The government held a referendum in which 95 percent of voters ―more than 3 million people ― rejected Brussels’ mandatory asylum-seeker quotas, though the minimum turnout of 50 percent of eligible voters was not reached.

Budapest’s continued resistance to EU immigration policies ― which Kovács described as “lagging behind reality” ― has drawn ire from the international community. In September, Luxembourg Foreign Minister Jean Asselborn said Hungary should be expelled from the bloc for treating asylum seekers “worse than wild animals.”

Human rights organization Amnesty International denounced Hungary’s “appalling treatment” of asylum seekers in a scathing report released in September. Men, women and children suffered “violent abuse, illegal push backs and unlawful detention at the hands of Hungary’s authorities” while spending months waiting for asylum in “degrading conditions,” the report said.

Hungary is training thousands of “border hunters” who will be deployed in May to patrol Hungarian borders with pistols, batons and pepper spray to keep migrants out.

This article has been updated to include additional information about the validity of Hungary’s recent referendum on migrant quotas.