Macedonia has finished building a fence on its frontier with Greece becoming the latest country in Europe to build a border barrier aimed at checking the flow of migrants and refugees.

A 3km-long metal fence was erected by the army at the Gevgelija crossing, on the main road north from the Greek city of Thessaloniki to Macedonia's capital Skopje.

For the time being the fence is not being erected at other locations, but Macedonian officials did not rule out such a possibility in the future.

The building of the 2.5m high fence, which started yesterday, sparked clashes between angry migrants and police.

Yesterday, a group of refugees trying to enter Macedonia pelted the police with stones while officers fired stun grenades in their direction.

Several police and army vehicles were damaged and 18 police officers slightly injured in the protests.

The situation later calmed down and was quiet today, according to an AFP photographer at the scene.

A Macedonian government spokesman said earlier the fence was aimed at ensuring migrants did not try to slip across the frontier undetected, without going through the checkpoint.

The border will remain open and only people who are from war-affected regions will be allowed to cross, spokesman Aleksandar Gjorgjev said.

Since the summer some central and southeastern European countries had begun tightening their borders to check the influx - a trend that has been accelerated by the 13 November terror attacks in Paris.

Two of the attackers slipped into Europe through Greece posing as refugees from Syria's civil war, according to French prosecutors.

Since then, countries along the migrant route through the Balkans have tightened restrictions on refugees, allowing entry only to those fleeing war-torn countries such as Syria, Afghanistan and Iraq.

Macedonia was taking a similar tack and the move had sparked protests from refugees and migrants that have been turned away.

From Macedonia, the refugees generally travel further north to Serbia and then back into the European Union via Croatia and Slovenia before arriving at their destination in Austria, Germany, Sweden or other western European countries.