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. However, Foreign Minister Peter Szijjarto told reporters yesterday 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.
But much of this emerging policy has yet to be put into practice, and new rules are rapidly being overtaken by events.
Earlier, migrants were being allowed to board trains at Keleti station in east Budapest, where many had tickets for the Austrian capital, Vienna, or for Munich in southern Germany.
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.
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?”
Hungarian Prime Minister Viktor Orban is due to meet senior EU officials on Thursday in Brussels to discuss the crisis.
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.
efugees should be fairly divided among EU member states
The German government has already said it will allow Syrians arriving from other EU states to apply for asylum. But yesterday, 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.
overning immigration to the EU – explained in 90 seconds
The 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.
Most of the dead were thought to be Syrians.
Hundreds more people drowned in the Mediterranean last week while trying to reach Europe from Libya.