Hungarian riot police fired tear gas and water cannon at crowds of refugees and migrants desperate to cross the border from Serbia, while others carved out a new route and headed for Croatia.
Tensions boiled over at the flashpoint Horgos-Roszke crossing where hundreds of furious people tore down the wire meshing separating them from Hungarian territory and police clashed for hours with migrants, some of whom threw stones, sticks and plastic bottles.
The unrest left 14 Hungarian police officers injured, authorities said.
Serbia lodged a formal protest with Hungary over the use of tear gas on its territory, and Interior Minister Nebojsa Stefanovic said police reinforcements were being sent to the Serbian side of the border to help calm tensions.
UN chief Ban Ki-moon said he was "shocked" by Budapest's actions, as hundreds of people fleeing war and misery, many of them Syrians, remained stranded at Hungary's newly fenced-off border.
"We want to leave! We want to leave to Germany!" cried one French-speaking man at a migrants' protest at the border through a megaphone.
"Open the door!" he added in English, with hundreds echoing his call.
Crowds who managed to overrun police lines and break through the fence in the Hungarian town of Roszke did not take advantage to run deeper into the central European country's territory however, apparently wanting instead to show their frustration after Budapest sealed the border on Tuesday (local time), an AFP correspondent said.
In the chaos, at least four children were separated from their families and apparently taken by police to a nearby border control building, rights group Amnesty International said.
"The families are desperate to be reunited with their children. Not only have they experienced the traumatic journey to the border and the use of force by the police, they have now lost the security of being with their parents," crisis response director Tirana Hassan said.
Gyorgy Bakondi, Hungarian Prime Minister Viktor Orban's chief adviser, said the tough response came an hour after the migrants had issued an "ultimatum" to police, demanding to be let through.
"We will repair the fence, in fact we will put up a stronger fence," he told a news conference.
Hungary also deployed three military vehicles mounted with guns some 100 to 200 metres from the border, an AFP reporter at the scene said.
The UN refugee agency has criticised Hungary's hardline anti-migrant stance, saying it could violate the 1951 Refugee Convention.
"I was shocked to see how these refugees and migrants were treated. It's not acceptable," UN Secretary General Ban Ki-moon told reporters when asked about the border clashes.
Hungary on Tuesday closed the razorwire-topped border while threatening three-year jail sentences against anyone who crosses illegally.
Earlier on Wednesday, migrants desperate to find new ways to eastern Europe were granted access by Croatia.
By Wednesday evening, some 1300 men, women and children had entered the Balkan nation, the interior minister said.
Pressure is building for an EU summit to come up with solutions to the continent's worst migration crisis since World War II, with the bloc bitterly split and free movement across borders – a pillar of the European project – in jeopardy.
Croatian Prime Minister Zoran Milanovic said all migrants could pass through the EU state, allowing them to push on towards Slovenia, Austria and Hungary's fenceless southwestern frontier.
"We are ready to accept and direct those people, their religion and colour of skin is completely irrelevant, to where they apparently wish to go – Germany and Scandinavia," Milanovic told MPs.
In an interview with French newspaper Le Figaro to be published on Thursday, Hungary's Orban said he also wanted to build fences on its borders with Croatia and Romania.
Germany, Austria and Slovakia have all reimposed identity checks on parts of their borders, and Poland and the Netherlands are considering whether to follow suit.
Politically, the big concern is for the future of Europe's 20-year-old Schengen agreement, which governs borderless travel between member states, and is considered as important as the euro by many EU supporters.
German Chancellor Angela Merkel and her Austrian counterpart Werner Faymann on Tuesday called for a special EU summit next week to debate the crisis.
European President Donald Tusk will announce a decision about the possible summit on Thursday.