Macedonia stepped up security on its border with Greece on Thursday, blocking thousands of migrants from entering and leaving them stranded on a dusty field.

The government said it is proclaiming a state of emergency on its borders and deploying army troops as it tries to stem a surge of migrants from the Middle East, Asia and Africa that has overwhelmed the economically-impoverished Balkan country.

Macedonian police spokesman Ivo Kotevski said that both police and the army will from now control the 30 mile stretch of the border in order to stop "the massive" influx of migrants coming from Greece.

"This measure is being introduced for the security of (Macedonian) citizens who live in the border areas and better treatment of the migrants," he said.

The measure could create a huge backlog of migrants on the Greek side of the border from which some 2,000 illegally have crossed into Macedonia daily. Hundreds of migrants from the Greek island of Kos planned to move into Macedonia in the next few days.

Until now, the border has been porous with only a few patrols on both sides. If the Macedonians seal the border, it would disrupt the so-called Balkan corridor for migrants that originates in Turkey and goes through Greece or Bulgaria to Macedonia and Serbia.

Macedonia has become a major transit route for the migrants heading from Greece to more prosperous European Union countries. Almost 39,000 migrants, most of them Syrians, have been registered passing through Macedonia over the past month, double the number from the month before.

Thousands of migrants were stranded Thursday in a no-man's land between Macedonia and Greece near the Macedonian town of Gevgelija, from which they planned to catch trains that would take them to the Serbian border on their way to EU-member Hungary. A police helicopter hovered nearby and officers in armored vehicles watched the crowd.

For months, the train station in Gevgelija was the scene of skirmishes between baton-wielding policemen and the migrants who were trying to secure a place on overcrowded trains.