Hundreds of people have massed at a closed crossing point near the Serbian town of Horgos, and are involved in a tense stand-off with police on the other side of the border.
Some migrants threw missiles, including stones and water bottles.
Many of the migrants want to reach Germany, amid divisions within the EU over how to deal with the crisis.
Tens of thousands of people have crossed into Hungary to enter the Europe Union’s Schengen zone, which normally allows people to travel between member countries without restrictions.
Hungary closed its entire border with Serbia on Tuesday after making it illegal to enter the country or damage a new razor-wire border fence. The country’s courts have started fast-track trials of arrested migrants.
Serbia’s foreign ministry – which has protested over the firing of tear gas and water cannon into its territory – says Hungary has now closed the main border crossing between the two countries to all traffic for 30 days.
There were chaotic scenes near 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 Hungarian side.
The Hungarian government says 20 police officers were injured as migrants tried to break through a gate.
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.”
United Nations Secretary General Ban Ki-moon has said he is “shocked” by the treatment of migrants.
Serbian minister Aleksandar Vulin, visiting the scene, said the migrants’ frustration was understandable after Hungary closed the border.
“Hungary must show it is ready and capable to accept these people,” he said.
Serbia has said it will send additional police to its border with Hungary and try to distance migrants from the fence.
“The aim is to prevent further attacks on the Hungarian police from our territory and in a humane and respectful way distance the migrants from the fence and the Hungarian police,” said Interior Minister Nebojsa Stefanovic in a statement.
Meanwhile, Croatia has said it will allow migrants to travel on to northern Europe, opening up a new route a day after Hungary sealed its border with Serbia.
A steady stream of migrants is crossing into Croatia from Serbia, with some of those stranded on Serbia’s border with Hungary now using the same route.
Croatian Prime Minister Zoran Milanovic said: “We are ready to accept and direct those people… to where they apparently wish to go.”