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 BBC’s Europe correspondent Chris Morris says the crisis has highlighted the limitations of the EU’s system for coping with refugees.
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 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.
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 prevented migrants from going inside.
An angry crowd chanted “Germany, Germany” and waved train tickets.