Budapest's move came after Austria and Slovakian authorities followed Germany's lead in reimposing border controls, a further body blow to Europe's cherished passport-free Schengen zone as the EU's border agency said more than half a million migrants had been counted at the bloc's borders so far this year.
With no sign of a let-up in the flow of refugees, German Vice Chancellor Sigmar Gabriel said that Europe had "disgraced itself" after EU ministers failed to agree on Monday how to share the burden. (READ: Austrian leader compares Hungary migrant treatment to Nazi era)
Hungarian police closed a 40-meter gap in a razor wire barrier for train tracks that had until Monday night been the main illegal crossing point and pushed migrants on towards a nearby official crossing point.
But on Tuesday morning, that official crossing at Roszke, and a second one at Asothalom, were also shut, leaving several hundred people stuck on the Serbian side with no apparent hope of entering the EU member state.
Around 20 Hungarian riot police stood behind a two-meter fence at Roszke while on the Serbian side of the barbed wire 300 migrants waited around 50 tents for the border to reopen, an Agence France-Presse reporter said.
"Why are they doing this?" one Afghan woman holding a child asked a volunteer, who was only able to give her a bottle of water. Several groups of people were seen walking along the border fence searching in vain for another way into Hungary.
Bashir, a 17-year-old schoolboy from Bazari in Afghanistan wanting to make it to Sweden or Norway, said that he arrived at the border an hour after it closed at midnight and was unable to cross.
"It was really bad last night. It was cold, particularly for families with little babies," he told AFP.
The closure came as harsh new Hungarian laws came into effect criminalising "illegal border-crossing" with up to three years in prison. Authorities on Tuesday announced the first arrests had been made under the new legislation.
Hungary, which has seen some 200,000 migrants enter the country this year, is also building a controversial four-metre high fence along the 175-kilometre (110-mile) border with non-EU Serbia.
With Poland and the Netherlands saying they were also considering border controls, there are fears the very ideal of a borderless Europe allowing passport-free travel to hundreds of millions of citizens could collapse – even though states are permitted to impose temporary controls for security reasons.
German Chancellor Angela Merkel's spokesman insisted Monday that the country was not slamming its doors to refugees but argued the new measures were needed to restore order to the asylum process.
The move caused long traffic jams on the border from Austria into the southern German state of Bavaria – which has seen 63,000 people arrive by train in the state capital Munich since August 31 – and major disruption to rail services.
Around 2,000 asylum-seekers still crossed the frontier into Germany on Monday, albeit at a slower pace than in recent weeks, federal police spokesman Rainer Scharf told AFP in the southern German town of Freilassing.
Vice Chancellor Gabriel said that Europe had "disgraced itself" after EU ministers failed in Monday's emergency meeting to reach unanimous agreement on a plan to share out 120,000 refugees.
This was aimed at easing the burden on frontline states – Hungary, Greece and Italy – from the tide of people fleeing war zones such as Syria and Afghanistan, but several members of the bloc, notably eastern members including Hungary, object.
Berlin on Tuesday suggested that EU aid could be cut to member states that refuse to take their share of migrants. Amnesty International said the EU had "once again dismally failed to show collective leadership."
But the crisis is moving faster than the 28-nation EU can handle, with the EU's Frontex border agency saying Tuesday that more than half a million migrants crossed the bloc's borders in the year to August 31, almost double the total for the whole of 2014.
However, the EU ministers did formally approve a plan first aired in May to relocate 40,000 refugees, as well as plans for military action against people smugglers in the Mediterranean, seizing and possibly destroying boats.
New boat tragedy
In another tragedy that underscored the dangers faced by migrants, at least 22 people including at least four children and 11 women were feared drowned when the wooden boat taking them from Turkey to Greece sank. Another 211 were rescued.
From Greece, migrants travel up through the western Balkans and enter Hungary, most of them seeking to travel on to Germany via Austria which saw around 20,000 new arrivals on Monday.
At Roszke train station in Hungary, migrants who managed to make it across the border on Monday were in a bad way, said Jota Echevarria, medical coordinator for Doctors Without Borders.
"The physical state of the people, 90 percent of them, if not 100 percent are very tired, and this affects much more the women and elder people and the children," he said.
"If we could work and live in safety we wouldn't be here," said Bashir, the Afghan.
"In Afghanistan... how are we supposed to live with no future? If I die I want it to be for something, for something good, for my rights." – Calin Neacsu and Eric Randolph, Agence France-Presse / Rappler.com