Police in Macedonia have fired tear gas at a group of refugees stranded for more than a week at the Greece-Macedonia border, as soldiers began erecting a metal fence to keep them out.

Alexandra Krause, an emergency coordinator at the UN Refugee Agency, told Al Jazeera from the Macedonian town of Gevgeliga on Saturday, that the move was prompted after a group of mainly Iranians, Moroccans and Bangladeshis started throwing stones at the police.

"Several police officers were injured. We don't know yet how badly they're injured," she said. "But as a reaction to this, police started using tear gas for a short while to disperse the crowd."

The interior ministry later said that 18 policemen were injured, two of whom were hospitalised after the incident.

The Reuters news agency reported that the crowd started to throw stones after one man, believed to be a Moroccan, was electrocuted and badly burned when he climbed on top of a train wagon and touched a power cable overhead.

Krause said there was a heavy deployment of police and military personnel at the border, where calm was said to have returned.

Metal fence

Earlier on Saturday, Macedonian soldiers began driving metal poles about three metres high into the cold, muddy ground, building a barrier similar to that erected by Hungary on its southern border.

Macedonia, along with other Balkan countries on the route to Western Europe, 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.

Klause confirmed that Syrians, Afghanis and Iraqis are being allowed to cross the border. She said that despite harsh weather conditions, on average 5,000 people were still arriving at the Macedonian border every day.

In a surge that began about 18 months ago, people of different nationalities have been flowing across Balkan borders, having landed by boat in Greece from Turkey.