Hungary's parliament authorized the government on Monday to deploy the army to help handle a wave of migrants, granting the military the right to use non-lethal force.
It passed a law saying the army could use rubber bullets, pyrotechnical devices, tear gas grenades or net guns, according to the text posted on parliament's website.
Hungary, a landlocked nation of 10 million, lies in the path of the largest migration wave Europe has seen since the Second World War and has registered more than 220,000 asylum-seekers this year.
Prime Minister Viktor Orban told parliament that police were unable to secure all Hungary's frontiers - which include outer borders of the EU's passport-free Schengen zone - without help from the army.
- Refugee situation at Croatia-Serbia border heats up — literally: Nahlah Ayed reports
- For many Syrian refugees, fleeing to Europe isn't the answer
- Refugee crisis: Thousands gather at Austrian border
- Refugee crisis: Girl, 5, dead, 13 missing off Greek island
- Refugee crisis spawns war of words among Eastern European leaders
"We can defend the Serbian stretch of the border," he said, adding that fortifications on that 175 kilometres-long section were working better than expected.
Hungary has built a fence on the Serbian border and deployed regular patrols, leading to a drastic drop of migrants crossing it. Instead, thousands have entered Croatia and Zagreb has waved them on to Hungary again.
Croatia is not a member of Schengen, and the two countries have exchanged bitter words over the handling of the migrants, with Budapest threatening to veto Croatia's Schengen accession and beginning work to fortify its border with Croatia too.
Hungary erected a steel gate and fence posts at a border crossing with Croatia on Monday, seeking to seal a route used by refugees and migrants.
"We can defend the Croatian stretch but to do that we need the army to patrol together with the police," Orban said.
He added Hungary would act on its own until the EU found common ground on how to handle the flow of migrants.
"Europe is rich but weak. That is the most dangerous combination possible," Orban said.
"The result ... is catastrophic. Because Europe cannot defend its external borders, internal borders are shut again.
"We need to rethink many European inventions, institutions and treaties. But until we do we cannot sit idle. Until the EU states act as one, member states will be forced to go out of their way to fend off this brutal threat."
The government took out ads in countries many migrants set out from. In Lebanon, the newspaper An Nahar on Monday carried a full-page warning in English and Arabic.
"Hungarians are hospitable, but the strongest possible action is taken against those who attempt to enter Hungary illegally," it said.
"The illegal crossing of the country's border is a crime punishable by imprisonment. Do not listen to the people-smugglers. Hungary will not allow illegal immigrants to cross its territory."
The radical nationalist Jobbik party, which has advocated even tougher measures, supported Orban's centre-right Fidesz party in the vote, which passed the law with 151 votes to 12 against and 27 abstentions in the 199-member parliament.
The Helsinki Committee, a rights group in Budapest, said the law was an unnecessary act likely to stir tensions.
"Hungary is not at war with refugees," Helsinki co-chair Marta Padravi told Reuters. "There is no armed conflict, neither at the Hungarian border nor in the country - but the army will have the powers to prevent the escalation of riots."
She said there was a danger the army might get involved in confrontations similar to one last week in which police clashed with angry migrants in the southern town of Roszke.
Croatia's Interior Minister Ranko Ostojic said on Monday Zagreb would demand that Greece stop moving migrants from the Middle East on to the rest of Europe, at a meeting of EU interior ministers on Tuesday.
The Associated Press also reported that Ostojic took the unusual step of trying to personally reassure asylum seekers.
Ostojic boarded a bus full of migrants Monday when he was visiting a newly established reception centre in Opatovac. As the television cameras followed, Ostojic told the group they would be given refreshments "and then you will be transported to Europe."
The German government said it had scrapped plans to deny benefits to asylum seekers who arrive in Germany via another EU member state, following resistance from the members of the centre-left Social Democrats.