BUDAPEST (Reuters) - Hungary unlawfully kept two migrants in a transit zone on its frontier with Serbia, the European Court of Human Rights ruled on Tuesday, in a finding which could affect its plans to detain thousands of asylum seekers in border camps.

Two Bangladeshi citizens, Ilias Ilias and Ali Ahmed, filed a suit against Hungary in September 2015, shortly after the government put up a fence on its southern borders and created two transit zones for asylum seekers in a bid to curb the number of migrants arriving via the Balkans.

The two men sought to be released from the transit zone and asked for their expulsion to Serbia be halted.

The court ruled that their detention in the transit zone was unlawful under the European Convention of Human Rights, but there was “no violation of the convention in respect of the conditions of detention at the transit zone.”

The Strasbourg court ruling is subject to appeal. The government was not immediately available for comment.

Hungary will have to pay 10,000 euros each to the two men, and will also have to pay a further 8,705 euros to cover their expenses and costs under the ruling.

The decision came just as Hungary passed legislation last week that aims to keep all migrants in detention camps on the border until their asylum requests are processed. The United Nations has criticized the new legislation.

The U.N. refugee agency UNHCR said last week the number of asylum applications in Hungary reached 177,000 in 2015. It fell sharply to 29,000 last year, with just 912 in the first two months of 2017.

All asylum seekers would be kept in a transit zone where the detention centers are located, effectively condemned to prolonged detention in shipping containers surrounded by barbed wire, a UNHCR spokeswoman said.

“This judgment is particularly relevant now in Hungary because the Strasbourg court has found that detaining asylum seekers in the transit zone without any formal procedure and access to judicial remedy is unlawful,” Marta Pardavi, co-chair of the Hungarian Helsinki Committee, which represented the migrants’ case in the court.

“This already ongoing practice of unlawful detention in the transit zone is exactly what the Hungarian newly adopted law foresees for every asylum seeker, so it’s clear: the new law is against the European Convention on Human Rights.”