By Karin Strohecker and Marton Dunai
VIENNA/BUDAPEST (Reuters) - A train carrying hundreds of migrants headed to Vienna on Monday after being held for hours at Austria's border with Hungary amid a security clampdown on trafficking gangs and efforts to apply fraying European rules intended to manage the flow of refugees.
Austrian Railways had cited "overcrowding" on the train and a police spokesman in Vienna said Austria wanted to check whether any of the migrants had already asked for asylum in Hungary. Those that had would have to stay on the Hungarian side. A second train from Budapest remained stuck at the border.
In sweltering hot sunshine the refugees -- many of whom are fleeing wars in the Middle East -- sat in crowded train corridors or wondered confusedly on the platform awaiting announcements.
Their plight highlights the humanitarian and diplomatic challenge facing the European Union, which has eliminated border controls between 26 states of the "Schengen area" but requires new asylum seekers to apply in the first member country they enter -- in this case Hungary.
Most of the tens of thousands of migrants entering Hungary from the Balkans this summer are heading to richer nations such as Germany and Austria. Hungarian authorities allowed the latest batch to board the westward bound trains after dozens protested late on Sunday about being stranded at the railway station.
Hungarian railway operator MAV said a train that left Budapest for Munich at 0910 GMT (0510 EST) was held at the border crossing of Hegyeshalom awaiting "authorities' action".
The Vienna police spokesman said migrants allowed into Austria could stay for two weeks while they decide whether to seek asylum there. Those who did not would be returned to their last transit country.
Earlier refugees had expressed relief at finally being allowed to leave Budapest.
"LIKE A DOG"
Sami, a 35-year-old Syrian, showed a Reuters reporter a newly purchased 120 euro ($134) ticket for the 1:10 p.m. (0910 GMT) train to Munich.
"I have been here sleeping on the floor like a dog with my two sons for six days," he said. "Today we leave this country behind and join my sisters in Munich, inshallah."
About 1,000 others waited on blankets outside the railway station hoping to follow them later.
Hungary has asked Germany to "clarify" the legal situation with respect to travel by illegal migrants within the EU.
In Berlin, the German government denied that there were "special trains" carrying migrants to Germany from Hungary. It said that under EU law asylum seekers arriving in Hungary must be registered there first.
German Chancellor Angela Merkel, whose country expects to receive some 800,000 migrants this year, the most of any EU country, said the crisis could destroy the principle of free movement in Europe enshrined in the Schengen accord.
Austrian authorities have stopped hundreds of refugees and arrested five traffickers in their clampdown, which followed last week's gruesome discovery of 71 dead migrants in an abandoned truck near the Hungarian border.
At a news conference in Vienna on Monday, Interior Minister Johanna Mikl-Leitner and one of her top deputies denied their actions violated the Schengen deal, though the clampdown caused a 25 km (15 mile) tailback of vehicles into Hungary on Monday.
Konrad Kogler, director general for public security at the ministry, told reporters the checks had been agreed with Germany, Hungary and Slovakia, and had already uncovered more than 200 refugees and five people smugglers.
"These are not border controls," said Kogler, noting that checks were taking place across Austria's territory as well. "It is about ensuring that people are safe, that they are not dying, on the one hand, and about traffic security, on the other."
Hungary's M1 motorway leading to Austria, which also borders Slovakia, Slovenia and the Czech Republic on its eastern side, clogged up due to the checks.
Hundreds of thousands of migrants are trying to reach the European Union, fleeing violence and poverty in the Middle East and Africa. More than 140,000 have been caught by Hungarian police on the Serbian border so far this year.
Over the past three days, Hungarian police said they had caught 8,792 migrants crossing into the country, most of them from Serbia.
A man from Afghanistan, named Saeed and aged 22, had said he had been in Hungary for two weeks and could hardly wait to board the Railjet train to Munich. He had the ticket. But he also had doubts he would make it there.
"The Hungarian police have cheated us so many times, I will only believe this in Austria."
Hungary plans to tighten laws on migration this week and also plans to set up holding camps near the Serbian border. The government said it may use the army to help police protect the borders if it gets the necessary parliamentary approval.
The changes will also impose stronger penalties for the illegal crossing of borders and for damaging a 175-km fence being built at the Serbian border, and would enable Hungary to expel migrants violating the new rules.
($1 = 0.8927 euros)
(Additional reporting by Anna McIntosh, Shada Nasrallah and Michael Shields; Editing by Gareth Jones)