BuzzFeed News has reporters around the world bringing you trustworthy stories about the impact of the coronavirus. To help keep this news free, become a member.

Citing COVID-19 concerns, a federal judge ordered US officials on Friday to release immigrant children detained at facilities for families by July 17.

"The [family residential centers] are 'on fire' and there is no more time for half measures," US District Judge Dolly Gee wrote.

The order comes a day after an independent monitor tasked with tracking how children in family detention centers are treated as part of a long-standing court agreement said 11 immigrants held inside a Karnes City, Texas, facility had tested positive for COVID-19. The independent monitor said the risk of immigrant minors and families contracting coronavirus inside one of the facilities continued to grow because some staffers failed to wear masks or observe social distancing requirements.

Gee reference the spotty or total lack of compliance to wearing masks and social distancing in her order.

The order applies to children detained by Immigration and Customs Enforcement (ICE) inside one of its three family detention facilities for more than 20 days. As of June 8 there were 124 children detained at these facilities.

The children can be released to a sponsor or with their parents, the judge said. However, ICE can detain children beyond the 20 days if a suitable sponsor isn't found, a parent declines the minor's rights to be released within that time, or if they fail to appear at a court hearing.

Judge Gee oversees a 1997 court settlement known as the Flores agreement that says the government can't detain children for more than 20 days. The terms of the agreement do not apply to parents, but do apply to children who arrived to the US with their parents or guardians. The Trump administration has been trying to get rid of the agreement in an effort to detain immigrant children and their parents indefinitely.

In April, Gee found that ICE and the Office of Refugee Resettlement, which takes custody of unaccompanied minors, had violated the settlement and ordered the prompt release of the immigrant children the two agencies were detaining, though she didn't set a deadline. Gee also told ICE to make individualized release determinations for the children and submit a report on their efforts to comply with the order.

Andrea Meza, director of RAICES' family detention services program, said shortly before the report was due ICE asked parents if they wanted to waive their children's rights and be detained with them indefinitely or allow their kids to be released to a sponsor while they remained in custody.

"Our families were put in a situation where they had to decide and make a Sophie's Choice, am I going to keep my child in detention during a pandemic," Meza said in May. "Or separate from my child."

Attorneys said the parents were being presented with a "binary choice" meant to separate families. In court documents explaining why some immigrant children weren't being released, ICE wrote "parent does not wish to separate."

At the time ICE denied offering immigrant parents a "binary choice" and said it was exploring all options in order to comply with Gee's order requiring them to release children in their custody who don't pose a public safety or flight risk.

Some immigration attorneys are worried ICE will not use its discretion to release children under Friday's order with their parents and ask parents once again whether they want to release their kids to a sponsor or have them be detained together indefinitely.

ICE operates three family detention centers, one in Pennsylvania and two in Texas. COVID-19 test results for families inside the South Texas Family Residential Center in Dilley, Texas, are still pending but four employees have tested positive, Gee's order said.

tag