Hundreds of migrants left Budapest aboard a packed train bound for a town near the Austrian border on Thursday after two days of chaos symbolic of a European asylum system brought to breaking point.

Exhausted and confused, migrants crammed onto a train to the Hungarian border town of Sopron, clinging to doors and squeezing their children through open carriage windows.

Trains to Vienna and beyond to Germany were canceled, making it unclear what would be the next stop for the migrants - many of them refugees from wars in the Middle East.

RELATED: Migrant death ship sinks off Libya.

Images of a drowned three-year-old face down in the surf on Turkish beach, one of at least 12 who died there the previous day while trying to sail for a Greek island, appeared in newspapers across the continent, increasing public pressure on politicians to take action.

"He had a name: Alyan Kurdi. Urgent action required - A Europe-wide mobilization is urgent," French Prime Minister Manuel Valls said on Twitter. The images appeared days after 71 bodies were found in an abandoned truck in Austria last week.

The influx has strained the European Union’s asylum system to breaking point, sowing division among its 28 nations and feeding the rise of right-wing populists.

The major EU countries have taken sharply opposing positions on whether to offer welcome. Germany plans to accept 800,000 refugees this year, while Britain has set up a program to allow in Syrians that has accepted just 216.

RELATED: Dozens of migrants found dead in truck.

"As one of the world's richest countries, with good infrastructure, a viable welfare state and a solid budget surplus, we are in a position to rise to the occasion," German Labor and Social Affairs Minister Andrea Nahles said at a briefing ahead of a G20 meeting in Turkey.

Nearly all of the migrants arrive on the EU's southern and eastern edges but press on for richer countries further north and west, creating havoc for a bloc that normally allows free movement internally but restricts it for undocumented migrants.

The train's departure from Budapest followed a two-day standoff with police barring entry to the station to more than 2,000 migrants. On Thursday the police stepped aside and the crowd surged past.

“We want to go to Germany but that train in the station, maybe it goes nowhere. We heard it may go to a camp. So we will stay out here and wait,” said Ysra Mardini, a 17-year-old from the Syrian capital Damascus, dressed in jeans and a T-shirt.

As the train departed, lawmakers were debating a raft of amendments to Hungary’s migration laws that the ruling party said would cut illegal border crossings to "zero".

They provide for the creation of holding zones on the country’s southern border with Serbia, where construction crews are completing a 3.5-metre-high fence.

Hungary has emerged as a flashpoint, as the primary entry point for those traveling overland across the Balkans. Its right-wing government is among the continent's most outspoken voices against allowing mass immigration.

Prime Minister Viktor Orban, in Brussels for talks with European leaders, said Hungarians and Europeans were “full of fear because they see that the European leaders ... are not able to control the situation.”

In an opinion piece for Germany’s Frankfurt Allgemeine Zeitung, he wrote that his country was being “overrun” with refugees, most of which, he noted, were Muslims, not Christians.

“That is an important question, because Europe and European culture have Christian roots. Or is it not already and in itself alarming that Europe’s Christian culture is barely in a position to uphold Europe’s own Christian values?” he asked.

More than 100,000 asylum seekers arrived last month alone in Germany. Prime Minister Angela Merkel has emerged as a leader on the issue, arguing that providing refuge for those fleeing persecution and war is a fundamental obligation.

Germany has begun accepting asylum claims from Syrian refugees regardless of where they entered the bloc, suspending rules which normally require them to register and remain in the first EU country they reach.

Berlin's generosity has caused confusion for its neighbors, which have alternated this week between letting migrants pass through and blocking them. Hungary allowed thousands to board trains for Germany on Monday but then called a halt to the travel, leaving migrants camped in the summer heat in central Budapest.

Relatives of three-year-old Aylan Kurdi, whose image drowned in a red T-shirt, blue shorts and tiny sneakers captivated the world, said the family were trying to reach Canada via Europe when they set off from the Turkish coast.

His 5-year-old brother Galip and mother Rehan, 35, also died after their boat capsized while trying to reach the Greek island of Kos. His father, Abdullah, was found semi-conscious and taken to hospital.

Abdullah’s sister Teema, a resident of Vancouver, said she heard the news from another of the boy's aunts: "She had got a call from Abdullah, and all he said was, my wife and two boys are dead," Teema Kurdi was quoted as saying in Canada's National Post newspaper.

The crisis has confounded the EU, which is committed to the principle of accepting refugees fleeing real danger but has no mechanism to compel its 28 member states to share out the burden.

EU Commission President Jean-Claude Juncker is expected to unveil proposals in an annual state-of-the-union address to the European parliament next week. Interior ministers hold an emergency meeting five days later.