Hundreds of migrants walk after leaving the transit zone of the Budapest main train station, on September 4, 2015
Budapest (AFP) - Hungary's parliament pushed through emergency anti-migration laws Friday to halt a surge in numbers crossing into the EU state as crowds of refugees and migrants defied the security forces in their quest to reach western Europe.
The new measures include three-year jail terms for people climbing over the newly built razor wire fence on the 175-kilometre (110-mile) border with Serbia, as well as new border "transit zones" to hold asylum seekers while their applications are being processed.
Lawmakers also declared a "state of crisis caused by mass immigration", which will allow the police and army to assist in registering asylum-applications and operate detention facilities in registration camps.
"If we do not protect our borders, tens of millions of migrants will keep coming to Europe," right-wing Prime Minister Viktor Orban said in a statement on Friday.
"If we allow everyone in, that is the end of Europe. We may one morning wake up and realise that we are in the minority on our own continent."
The legislation changes came as hundreds of desperate migrants trapped in Hungary tried to leave the country.
- Walk to the border -
More than 1,000 people stranded for days in makeshift camps at Budapest's main train station set off on foot to the Austrian border, some 175 kilometres (110 miles) from the Hungarian capital.
The crowd included people in wheelchairs and on crutches, as well as parents carrying children on their shoulders. Some flashed victory signs while others waved images of German Chancellor Angela Merkel, who recently announced that Berlin was easing asylum restrictions for Syrians.
"We are very happy that something is happening at last. The children are very tired, Hungary is very bad, we have to go somehow," a young Syrian from Aleppo told AFP.
Meanwhile, another 500 were involved in a 24-hour stand-off with police in the town of Bicske, some 40 kilometres west of Budapest, where they refused to leave a train and be taken to a nearby refugee camp.
According to Hungarian news wire MTI, between 200 and 300 suddenly broke away from the station and ran into nearby undergrowth without police being able to stop them.
And in a further sign that migrants' frustration was boiling over, several hundred fled Hungary's main refugee processing centre near the town of Roszke, forcing the temporary closure of the border crossing with Serbia.
Some 300 still remained missing on Friday afternoon, police reports said.
Hungary has in recent months joined Italy and Greece as a "frontline" state in Europe's migrant crisis, with 50,000 people trekking up the western Balkans and entering the country in August alone.
A record 3,300 migrants crossed into Hungary on Thursday, latest figures from the UN refugee agency showed.
On Thursday, Orban defended his handling of the crisis during EU talks in Brussels, blaming Germany's lifting of asylum rules for the thousands of migrants travelling through his nation.
"The problem is not a European problem, the problem is a German problem," he stressed.
The Hungarian leader also said the huge number of Muslims among the migrants were a "threat" to Europe's Christian identity.