More than 1,000 refugees boarded scores of buses provided by Hungary's government and arrived before dawn at the border with Austria.

They refugees, from the Middle East and Asia, were exhausted after breaking away from police and marching for hours toward Western Europe.

The breakthrough became possible when Austria announced that it and Germany would take the migrants on humanitarian grounds and to aid their EU neighbour.

Austrian chancellor Werner Faymann announced the decision early today after speaking with German chancellor Angela Merkel.

Hours before, Hungary had announced it would mobilise a fleet of buses to take the weary travellers overnight from Budapest's main international railway station and from the roadside of the country's main highway and carry them to the Austrian border.

In jubilant scenes on the border, hundreds of refugees bearing blankets over their shoulders to provide cover from heavy rains walked off the buses and into Austria.

Volunteers at a roadside Red Cross shelter offered them hot tea and handshakes of welcome. Many collapsed in exhaustion on the floor, smiles on their faces.

Janos Lazar, chief of staff to Hungary's prime minister, said they had reversed course and stopped trying to force refugees to go to state-run asylum shelters.

He said the refugees' movements were putting rail services in danger and causing massive traffic jams: "Transportation safety can't be put at risk."

The asylum seekers, mainly from Syria, Iraq and Afghanistan, have often spent months in Turkish refugee camps.

They have then taken long journeys by boat, train and foot through Greece and the Balkans, and crawled under barbed wire on Hungary's southern frontier to a frosty welcome.

While Austria, on Hungary's western border, says it will offer the newcomers asylum opportunities, most say they want to settle in Germany.

Since Tuesday morning, Hungarian authorities had refused to let them board trains to the west, and the migrants declined to go to a processing centre, fearing they would face deportation or indefinite detention in Hungary.

Government spokesman Zoltan Kovacs told The Associated Press they were providing buses to move migrants west as an exceptional measure.

He said Hungary would continue to abide by European Union rules, which includes an obligation to register all asylum seekers at the first EU point of entry.

Hundreds continue to flow through Hungary's southern border with non-EU member Serbia daily, and tens of thousands of more migrants travelling through Greece and the Balkans soon could reach Hungary.

"The situation at Keleti train station, on the highways and on the train lines threatened to shut down part of Hungary's transportation system, which led to the decision to take the migrants to the Hungarian side of the border," Mr Kovacs said.

Abdullah Baker, a 26-year-old physician from the war-ravaged city of Aleppo in Syria, said he wants to work at a hospital in Freiburg, Germany, where a friend is already employed.

He left his parents and four sisters behind. He and two friends were among the few Syrians on an Austrian-bound bus carrying about 50 people.

"My family had tears of joy when I told them about the bus," he said. "We always fear the unknown but I long for closure."

Mohammed, a 35-year-old Syrian man who was packing his belongings in the sunken plaza of Keleti and informing other migrants about the buses, said he was happy to be leaving Hungary.

"The situation is so ugly here and I want to send (a) message to all Syrian people and all refugee people: Do not come to Hungary," he said.

Such comments reflect the reality that asylum seekers see limited opportunities and a less welcoming atmosphere in Hungary than in Germany, Sweden and other Western nations.

In what the Hungarian media called a "day of uprisings," about 350 people broke through a police cordon and began heading to Austria, 85 miles to the west, on the tracks.

Surprised riot police scrambled for their helmets as the crowd surged from the front of the train.

One man, a 51-year-old Pakistani, collapsed about 800 yards from the railway station and died despite efforts to rescue him.

Those left behind, mostly women and children, were boarded onto buses and taken to the nearby asylum centre.

Hours earlier, about 2,000 people set out from the Keleti station for a 106-mile to the Austrian border.

At first police tried to block them, but they quickly gave up. By nightfall, the marchers had already covered about 30 miles.

Along the way, there were some gestures of support. Many people flashed the V-sight for victory, while some handed out bottles of water to the weary travellers.

A small number made clear the new arrivals were not welcome. "Go home already," one man shouted in Hungarian from a passing car.

The Hungarian parliament tightened its immigration rules, approving the creation of transit zones on the border with Serbia where refugees would be kept until their asylum requests were decided within eight days.

Refugees would have limited opportunity to appeal against those decisions.

Across Europe, the refugee crisis is becoming more dramatic.

In Geneva, the UN refugee agency said nearly 5,600 people crossed from Greece to Macedonia a day earlier, roughly double the already high 2,500 to 3,000 per day in recent weeks.

Antonio Guterres, the head of the UN refugee agency, urged the EU to create a "mass relocation programme ... with the mandatory participation of all EU member states" for would-be recipients who clear a screening process.

He said a "very preliminary estimate" would be for the creation of at least 200,000 places to be added across the bloc.

The UN comments came after recriminations among EU leaders.

Hungarian prime minister Viktor Orban has said the human wave is a German problem, but Ms Merkel said the obligation to protect refugees "applies not just in Germany, but in every European member".

Mr Orban reiterated his determination to stop the refugees.

"Today we are talking about tens of thousands, but next year we will be talking about millions, and this has no end," he said.

"We have to make it clear that we can't allow everyone in, because if we allow everyone in, Europe is finished.

"If you are rich and attractive to others, you also have to be strong because if not, they will take away what you have worked for and you will be poor, too."