Thanks to a ruling on December 13 from the European Court of Human Rights, thousands of migrants and asylum seekers arbitrarily detained in Malta each year may finally have a way to challenge their imprisonment.

Growing numbers of migrants and asylum seekers from Eritrea, Somalia, and now Syria pay smugglers to take perilous, sometimes fatal boat journeys across the Mediterranean. Some 15,900 people arrived in the EU by this route in 2012, whereas 31,000 have crossed in the first nine months of 2013. As of October 2013, Syrians are now the largest national group attempting this crossing, while Eritreans and Somalis still come in significant numbers.

Many find themselves in Maltese territorial waters when their rickety crafts go into distress. Malta, to its credit, rescues them and brings them to shore. Yet Malta’s practice until now has been to place virtually all of these migrants and asylum seekers in detention.

When I met Stéphane in Malta in July 2012, he had been detained for seven months in one room with more than 200 adults he didn’t know. He left home in Côte d’Ivoire alone at 16 for the dangerous journey north: “My family was persecuted, there was violence and war. I went through Niger, Mali, and to Libya, in trucks. Then from Libya to Malta by boat…. For someone at 17 to be in detention, it's not normal. Seven months of detention, it's not normal.”

Detainees like Stéphane have had had no way of challenging their detention under Malta’s current system, which makes the detention arbitrary, in violation of European and international law. A long list of august bodies  have condemned Malta’s detention practices, including the UN Committee on the Rights of the Child, the Council of Europe’s Commission against Racism and Intolerance and Commissioner for Human Rights, the UN High Commissioner for Refugees,  and leading Maltese nongovernmental groups. The European Court has issued substantive judgments against Malta criticizing their detention practices not once, not twice, but three times.

The Maltese government has resisted change, in part by appealing the European Court rulings. This week’s verdict, which denies those appeals, makes it clear that Malta must reform its immigration detention system. The government needs to ensure that detainees have fair, speedy reviews of the lawfulness of each individual case of detention. In addition, the government needs to improve conditions of detention for those who continue to be held after these reviews.

This ruling can be particularly important for unaccompanied migrant children like Stéphane, who make the dangerous journey north without parents or other guardians to protect them. Malta’s policy, until now, has been to detain these children while determining their age. They’re left locked up for weeks or months with unrelated adults, vulnerable to abuse. Children should never be detained for immigration reasons, according to the world’s leading body on children’s rights. Thanks to this ruling, migrant children arriving in Malta will have better opportunities to challenge this detention.

There are much better options than detention. Malta already uses open reception centers for certain migrants. This ruling should prompt them to expand use of these centers. The European Union,  recognizing that this tiny country takes in a disproportionately large share of the migrants trying to reach the EU, should provide additional support for the open centers.

As the number of people trying to cross the Mediterranean by boat grows, with thousands of Syrian refugees joining the flow of desperate people, this ruling couldn’t come at a more critical time. Let’s hope the government makes these changes rapidly.