Hungary shut its main border crossing with Serbia on Friday after about 300 migrants escaped from a nearby refugee camp, police said.
"In the interest of preventing accidents, the police have temporarily closed the Roszke motorway border crossing to incoming traffic and are redirecting traffic to (a national road)," police said in a statement.
The move came after around 300 people broke through a fence of a nearby refugee camp.
"The police have taken the necessary steps to apprehend them," police said.
Hungary has become one of the flashpoints in Europe's migrant crisis in recent weeks, as thousands of refugees cross into the country on their way to Germany, which recently eased asylum restrictions for Syrians.
On Friday, some 500 migrants faced off police for a second day in the town of Bicske, refusing to get off a train that they believed would take them to the Austrian border, but that had stopped just 40 kilometres out of the capital, with police attempting to remove the refugees and place them in a camp.
The stand-off came as Hungarian lawmakers prepared to debate tough new anti-immigration measures, including criminalising illegal border crossing and vandalism to the new anti-immigrant razor-wire fence erected along the border with Serbia.
An estimated 2,000 migrants remained sheltered in a concourse underneath Budapest's Keleti station on Friday, waiting for trains to take them toward western Europe.
Hungary's handling of the migrants, who have been stuck for days, sometimes even weeks, in makeshift camps at the station, has caused confusion and anger.
After unexpectedly allowing several thousand to board trains for Austria and Germany on Monday, authorities suspended services for 48 hours, then reopened it on Thursday, only to have the national railways announce that it was suspending service to western Europe for "security reasons."