Migrants stranded as Hungary bars them from rail station
Hundreds of migrants are stranded outside a major railway station in the Hungarian capital, Budapest, after police sealed off the terminal to stop them travelling through the EU.
Government spokesman Zoltan Kovacs defended the closure, saying Hungary was trying to enforce EU law.
Thousands of people, many fleeing war and persecution, are trying to reach northern Europe to claim asylum.
EU states are engaged in a flurry of diplomatic activity to find a solution.
The crisis has highlighted the limitations of the EU's system for coping with refugees, the BBC's Chris Morris says.
Under an EU rule known as the Dublin Regulation, refugees should seek asylum in the first EU country they enter. But with countries such as Italy and Greece saying they cannot cope with the numbers, many have headed north.
Hungary had earlier appeared to abandon efforts to register migrants, allowing huge numbers to board trains at Keleti station in east Budapest and travel to Vienna and southern Germany on Monday.
Analysis by Chris Morris, BBC's Europe correspondent
The European Union is supposed to have a common asylum system but at the moment it's not worth much more than the paper it's written on.
Many of the migrants currently trying to reach Germany via Hungary probably arrived first in Greece. But they left the EU to travel through Macedonia and Serbia before crossing back into Hungary. Now the Hungarian government says it is trying to apply EU law, but it clearly doesn't want them to stay.
In other words the system is close to breaking point and needs reform. Most of the ideas being discussed at the moment - a fairer distribution of asylum seekers around Europe, much more help for Greece and Italy to register arriving migrants, and more effective action to send failed asylum seekers home - have already been approved by EU leaders.
But much of this emerging policy has yet to be put into practice, and new rules are rapidly being overtaken by events.
But police evacuated the station on Tuesday, leaving about 1,000 migrants outside.
The station later allowed non-migrant passengers to enter via a side entrance, but lines of police kept migrants out.
An angry crowd chanted "Germany, Germany" and waved train tickets.
This West African entered the Spanish territory of Ceuta from Morocco curled up next to a car engine. Read the full story here.
Many protesters in Budapest complained that they had paid hundreds of euros for tickets to Austria or Germany.
One 20-year-old woman from Aleppo, Syria, named only as Marah, said her family had bought six tickets for a train to Vienna.
"They should find a solution," she told Reuters news agency. "We are thousands here, where should we go?"
Rights group Hungarian Helsinki Committee described the situation at Keleti station as "very tense and unpredictable".
Correspondents say Hungary's action appeared prompted in part by pressure from other EU states struggling to cope with the influx of migrants.
About 3,650 arrived in Vienna by train on Monday, many intending to carry on to Germany. German police said 3,500 asylum-seekers arrived in Bavaria on Tuesday while Belgium and Sweden also reported a surge in migrant numbers.
Hungarian Foreign Minister Peter Szijjarto told reporters on Tuesday that Hungary would now register all migrants and send those it considered to be economic migrants back to the state from which they entered the country.
Prime Minister Viktor Orban is due to meet senior EU officials on Thursday in Brussels.
The number of migrants entering Europe has reached record levels, with 107,500 arriving in July alone.
Germany expects to take in 800,000 migrants this year - four times last year's total.
German Labour Minister Andrea Nahles said the influx meant between 240,000 and 460,000 more people could be entitled to social benefits next year, costing the state billions of euros.
The German government has already said it will allow Syrians arriving from other EU states to apply for asylum. But on Tuesday, a spokesman said the Dublin Regulation had not been suspended.
"Dublin rules are still valid and we expect European member states to stick to them," an interior ministry spokesman said.
Meanwhile, the EU's Frontex border agency said a trade in fake Syrian passports had emerged, mainly in Turkey.
"They know Syrians get the right to asylum in the European Union," Frontex chief Fabrice Leggeri told French radio.
Risks for migrants travelling through Europe were highlighted last week by the deaths of 71 people found in a lorry that had travelled to Austria from Budapest.
As a result, Austria has reintroduced border controls at main crossings from Hungary.
10 days of the migrant crisis
- 21 August: Crowds of migrants rush at Macedonian border forces in an attempt to enter from Greece
- 27 August: Hundreds of people are feared dead after two boats carrying about 500 migrants sink in the Mediterranean, off Libya; more than 300,000 migrants have risked their lives trying to cross the Mediterranean this year, according to the UN
- 27 August: A lorry abandoned near Parndorf in Austria is found to have 71 dead people inside, including four children
- 28 August: Twenty-six migrants are rescued from a van in Austria, near the border with Germany
- 1 September: Hundreds of migrants arrive by train in Munich, after Hungary abandons efforts to register them