The decision by the European Court of Justice goes against advice from its advocate general, 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 some 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.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)