Hungary is to close two migrant transit zones on its borders that critics described as effectively prison camps for hundreds of refugees.
During Europe’s 2015 migration crisis when well over a million people crossed into the continent, hard-line anti-migration Prime Minister Viktor Orban closed Hungary’s southern border – shutting down a key route for the movement of people.
About 300 have been stuck for more than a year in the transit zones between Serbia and Hungary – also the frontier of the European Union.
Shipping containers are used for housing and the sites are surrounded by barbed wire and guards.
They have been subject to lawsuits and were closed after the EU ruled they were illegal. Human rights groups said the migrants, who are mainly from the Middle East, were moved to other facilities after the top EU court ruled last week that two Afghans and two Iranians had effectively been detained and should be released.
"The Hungarian government disagrees with the ruling. We consider it a risk to European security, but as an EU member state, we will honour all court rulings," said Mr Orban’s chief of staff Gergely Gulyas.
The Hungarian Helsinki Committee, an activist group which pushed for the closure of the zones, gave a warning that asylum in the EU via Hungary would be harder now after the government said applications would have to be submitted at consulates in neighbouring countries.
"This is a significant victory for everyone who is locked up in metal containers behind barbed wires in Hungary. It's also a victory for all Hungarian citizens because the Court's judgment strengthens protection against arbitrary detention," said Marta Pardavi, co-chairwoman of the Hungarian Helsinki Committee.
“This judgment will also have a significant impact in the coming discussions on the future of the European asylum system as it reinforces essential human rights and asylum safeguards.”
But the group said that the 300 migrants could "expect virtually no shelter from Hungary amid their persecution".
Government spokesman Zoltan Kovacs disagreed, however, and said Hungary is surrounded by safe countries.
"The Geneva Conventions stipulate refugees must apply for asylum in the first safe country," he said.
"Nothing guarantees the right to choose where to apply, while breaking the law as an illegal migrant to boot."