Hours after a new law to stop refugees from crossing illegally came into force, Budapest has declared a state of emergency on its southern border. On Monday, more than 9,000 people entered the country.
Hungary was set to deploy the army to help guard its border with Serbia as it declared a "state of emergency" on Tuesday.
Hours earlier, authorities blocked several entry points along the frontier and officials revealed that a record 9,360 people had entered the country on Monday. The figure was nearly double the previous number of new arrivals, recorded last week.
The sealing of the border coincided with tough new laws preventing people from crossing illegally into Hungary from Serbia, which took effect at midnight.
Under the new rules, refugees who arrive by land at its border will automatically be turned back. Those arriving at the Serbian border should be rejected within a few hours.
Serbia accused Budapest of breaking a "promise" by closing its main border crossing, leaving thousands of migrants stranded between the two countries.
A controversial 175-kilometer (108 mile) fence, ordered by Prime Minister Viktor Orban, was completed over the past 24 hours.
The structure, which was denounced by the EU and human rights groups, is also 3.5 meters (11.4 feet) high. A boxcar bristling with razor wire was deployed at the Roszke crossing to help deter migrants.
First arrests under new law
Nine Syrian and seven Afghan migrants were detained a short time after the new controls took effect. The refugees were suspected of lifting the razor wire fence to get into the country, which is now a crime. They could face imprisonment or deportation.
But despite the new measures, earlier officials stressed that the country would still accept refugees through its official border crossings.
"We are going to close the green borders, the natural borders. That also means that the official and legal ways to come to Hungary, and therefore to the European Union, remain open. That's all we ask from all migrants - that they should comply with international and European law and, say the Schengen protocols, and they should come to the legal crossing points," said government spokesman Zoltan Kovacs.
Hungary wants to register refugees before allowing them in, having allowed tens of thousands of people to cross the country towards Germany, Austria and Scandinavian countries over the past few months.