The Mexican government must immediately release detained migrants who are especially vulnerable to the novel coronavirus and grant them temporary residence rights to ensure access to health and social services, a judge has ruled.

The measure, ordered by a Mexico City district judge in a provisional ruling published on Friday, would apply to migrants more than 60 years of age and those who have a disability, chronic illness or other condition that places them at higher risk of contracting COVID-19.

More:

The judge also instructed authorities to implement a series of measures to ensure access to medical care, health information, water, personal hygiene and contact with relatives for migrants in immigration facilities.

The ruling came after the Institute for Women in Migration (IMUMI), Sin Fronteras and Foundation for Justice and the Democratic Rule of Law, in coordination with more than 40 other groups, filed a lawsuit, arguing the government was not providing adequate protection to detained migrants during the pandemic.

"The resolution is quite complex and unusual," said Lorena Cano, an IMUMI lawyer.

It is difficult in Mexico to obtain a district court with such a broad scope, applying to all migrants and asylum seekers inside and outside of immigration facilities across the country, Cano told Al Jazeera.

"It is very encouraging," she said.

Lack of healthcare

COVID-19 is spreading rapidly in Mexico. The country now has 7,497 confirmed cases, and 650 people have died from the virus, an increase of more than 100 deaths in the last 24 hours.

There have been no cases reported among detained migrants, but migrant and human rights groups have raised alarm about lack of access to adequate healthcare, food, and sanitary conditions in immigration detention for years.

"In the larger facilities, in Mexico City and Tapachula, people have lost their lives due to lack of medical attention," said Cano.

"All of those conditions and human rights violations are what led us to present the legal action," she said.

In the past month, migrants have protested conditions in at least five immigration detention centres in different parts of the country.

A 42-year-old Guatemalan asylum seeker died of asphyxiation as a result of a fire set amid protests inside an immigration detention centre in Tenosique, in southern Mexico on March 31.

Migrants from Haiti and parts of Africa react during a protest outside the Siglo XXI immigrant detention centre [File: Jose Torres/Reuters]

Two days later, the Mexican National Immigration Institute issued a statement outlining coronavirus-related protocols for immigration facilities, including distancing measures between beds and provision of a less-trafficked space for those in vulnerable groups.

Immigration officials must now provide a full accounting of all detainees, implement additional health protocols, provide access to healthcare, information, and other services, and free those belonging to vulnerable groups, according to the district judge's ruling.

Authorities must also "establish a strategy, in compliance with existing social programs, for people in situations of migration or requesting international protection to access economic benefits that support their livelihood," the ruling said.

The judge gave officials until Monday to inform the court of compliance with the ordered measures but the government also has until Wednesday to file an appeal, said Cano.

"We will have to see what the reaction of the National Immigration Institute will be," she said.

The National Immigration Institute was not immediately available for comment.