Police in Macedonia fired tear gas and stun grenades at desperate refugees stranded for days at the Greek border and who are demanding passage to western Europe, as soldiers began erecting a metal fence to keep them out.
Macedonia's interior ministry said 18 police officers were injured, with two hospitalised. Some 20 refugees were treated for head injuries and breathing problems, aid groups told Associated Press news agency.
Macedonia, along with other Balkan countries on the refugee route, began turning away "economic migrants" nearly two weeks ago. Human rights groups have criticised the decision, under which only Syrians, Iraqis and Afghans are allowed through.
The new restrictions triggered days of protests from Iranians, Pakistanis, Moroccans and others, stranded in squalid tent camps on the border. Some Iranians have sewn their lips shut. One man on Saturday threw himself on railway lines before the police, screaming and flailing.
The latest violence on Saturday (local time) broke out after one migrant, believed to be a Moroccan, was electrocuted and badly burned when he climbed on top of a train wagon.
An angry crowd surged towards lines of Macedonian police and began throwing stones, a photographer at the scene said.
Police responded with tear gas and stun grenades, driving the crowd back, a witness said. Some officers threw stones.
Close to 250 people were involved in the clashes on the Greek side of the border, AP reported, with some 800 people stranded.
"I have been here for 10 days with my two sons," Iranian woman Fatemeh said. "We have decided to return to Athens and see what we will do."
Refugees desperate to reach western Europe
In a surge that began about 18 months ago, refugees have been flowing across Balkan borders, having landed by boat in Greece from Turkey.
Throughout 2015, close to 720,000 refugees - mainly from Syria, Iraq and Afghanistan - have arrived in Greece.
Most then travel onwards through Macedonia, the International Organization for Migration said. The most popular route for refugees sees them move further north towards Germany and Scandinavia.
Many of those refused entry to Macedonia from Greece are from Iran, Pakistan and Morocco.
Human rights groups say international conventions required countries to treat asylum requests on merit, not on the basis of nationality.
Macedonia erects fence at border with Greece
Earlier on Saturday, Macedonian soldiers began driving metal poles around three meters high into the cold, muddy ground, building a barrier similar to that erected by Hungary on its southern border.
European Union member Hungary in September and October sealed its southern border to refugees, calling them a threat to the security, prosperity and "Christian values" of Europe.
But the Macedonian government said it had no intention of sealing its border completely. A government spokesman said the aim of the fence was "to direct the inflow of people towards the controlled points for their registration and humane treatment."
"We would like to underline that the border will remain open," said spokesman Aleksandar Gjorgjiev. "We will allow passage for the people who come from war-affected regions as we have done thus far."
Macedonia, Serbia and Croatia said they began filtering the migrants after Slovenia, further along the route, announced it would start doing the same.
The number of refugees making the journey to Europe rose dramatically this year compared to 2014, although the influx showed signs of decreasing as winter approaches.
Germany expects roughly one million refugees and migrants to arrive this year alone.