Macedonia has declared a state of emergency and deployed the army to prevent thousands of immigrants and asylum seekers entering the country illegally on their way to western Europe.

"Due to an increasing pressure on the southern border... it is estimated that bigger and more efficient control is needed in the region where illegal border crossings from the Greek side have been massively registered," a statement from the Macedonian government said, according to an AFP news agency report.

In the border city of Gevgelija several thousand migrants attempting to enter Macedonia from Greece have been left stranded, reports Radio Free Europe. Two cargo trains and one one passenger train have been stopped on the border, and the international railway linking Thessaloniki with the Macedonian capital Skopje has been blocked by thousands of migrants.

The announcement comes the day after the Macedonian government announced it was running out of trains to transport migrants passing though the country. Nearly 39,000 migrants, most of them fleeing the country's civil war, have been registered passing through Macedonia in the past month, nearly twice as many as the month before. Many pass through the Balkans to Hungary, hoping to settle in wealthier countries in western Europe.