Mr Ban said such treatment of asylum seekers was "unacceptable".
Hundreds were involved in clashes at the Hungary-Serbia border on Wednesday, trying to breach a razor-wire fence.
More than 5,000 migrants have entered Croatia so far - avoiding Hungary - police say, and another 7,266 entered Germany on Wednesday.
German police said this was more than double the number that crossed the previous day, adding that most were picked up on the border with Austria.
Germany is the final goal of many migrants, as the European Union remains divided over how to deal with the crisis.
Hungary defended its action, saying that 20 police officers were injured as migrants tried to break through a gate, and a spokesman accused migrants of using children as "human shields".
At least two migrants were also injured, Hungarian and Serbian officials said.
Hungary closed its entire border with Serbia on Tuesday after making it illegal to enter the country or damage the border fence. The country's courts have started fast-track trials of arrested migrants.
More than 200,000 people have already crossed into Hungary this year to enter the EU's Schengen zone, which normally allows people to travel between member countries without restrictions.
Many are now heading for the Croatian border. Croatian police said 5,650 had crossed into the country.
Interior Minister Ranko Ostojic told national TV that the police were currently in control of the situation but if migrants continued to arrive in large numbers the authorities would have to think about taking a different approach.
On Wednesday officials said Croatia would allow migrants to travel to northern Europe.
Several hundred left the border by train, but thousands more have gathered to wait for further trains.
In other developments:
On Wednesday, there were chaotic scenes near the Hungarian town of Horgos, with fires burning and police vehicles and ambulances arriving on the Serbian side of the border, across from massed ranks of riot police on the other side.
Some migrants threw missiles, including stones and water bottles.
The firing of tear gas and water cannon created a stampede of migrants away from the border.
Several people received treatment from the Serbian ambulance service, some suffering the effects of tear gas.
Migrant Amir Hassan, from Iraq, said: "We fled wars and violence and did not expect such brutality and inhumane treatment in Europe."
Serbian Prime Minister Aleksandar Vucic accused Hungary of being "brutal and "non-European".
Serbia has said it will send additional police to its border with Hungary.