European Union member states do not have to issue entry visas to people at risk of torture or inhuman treatment, the EU's top court has ruled, cutting off a possible channel for refugees.
The decision by the European Court of Justice goes against advice from its chief lawyer, who said last month that such visas had to be issued under EU law.
The court ruled on a case of a Syrian family from the city of Aleppo who applied for a visa to stay with acquaintances in Belgium in October.
Belgian authorities had refused the visa, leading to a court battle.
"Member States are not required, under EU law, to grant a humanitarian visa to persons who wish to enter their territory with a view to applying for asylum, but they remain free to do so on the basis of their national law," the court said.
Belgium's immigration minister had said at the time that ruling in favour of humanitarian visas would "throw the gates wide open" to asylum-seekers.
The ruling comes as the EU is trying to curb immigration after taking in around 1.6 million refugees and migrants who arrived across the Mediterranean in 2014-2016.
EU states have struggled to accommodate the influx, ensure security screening and agree between themselves on how to share out the responsibility.
The bloc has also started to arrange treaties with countries south and east of the Mediterranean to have them block people on their way to Europe and be able to send them back more easily.
Hungary to detain migrants in border camps, alarming UN
Hungary has approved plans to detain migrants in camps on its border, state news agency MTI said, a step which the United Nations said violates European Union law and will have a "terrible physical and psychological impact" on asylum-seekers.
The measures, passed by parliament, will also tighten controls on Hungary's border, which has been a focal point of Europe's migration crisis since 2015.
The southern border with Serbia marks the external frontier of the EU's passport-free Schengen area, and hundreds of thousands of people have crossed into the country.
Prime Minister Viktor Orban sought to justify the move, saying Hungary had to act to defend itself and describing the influx of migrants - many of them fleeing conflict in the Middle East and Africa - as a "Trojan horse for terrorism".
Mr Orban's chief of staff said last month that Hungary planned two or three camps along its southern border, where migrants will be kept while their applications for asylum are processed.
Migrants whose applications are not immediately approved will not be allowed to move freely around Hungary but will be detained in camps that they can only leave outward, toward Serbia, according to the bill approved by parliament.
UNHCR spokeswoman Ccile Pouilly said that would effectively condemn asylum seekers, including children, to prolonged detention in shipping containers surrounded by barbed wire.