The ruling is part of an ongoing effort to release immigrants held in detention who are particularly susceptible to the coronavirus given the confined settings at facilities and the potential for spread.
In her order, Judge Dolly M. Gee of the US District Court for the Central District of California called for the swift removal of migrant children who are at one of the three family detention centers, which are run by Immigration and Customs Enforcement and located in Texas and Pennsylvania.
The children must be released with their parents or to "available suitable sponsors or other available COVID-free non-congregate settings" with the consent of their parents or guardians, Judge Gee said.
As of June 8, there were 124 children in ICE custody, according to the ruling. The ruling, which calls for children to be let go by July 17, applies to children who have resided at the three facilities for more than 20 days.
The efforts, Gee wrote, must be made with "deliberate speed."
Overall, around 8,858 tested overall detainees in ICE custody who have been tested for coronavirus and 751 have tested positive, according to the agency's statistics as of Friday afternoon.
CNN has reached out to ICE for comment.
Last month, House Democratic lawmakers urged the Trump administration in a letter to explain reported incidents of ICE asking migrant families in detention to choose between staying with their children or releasing them.
Advocates and immigration lawyers shared anecdotes of detained families distraught over their encounters with ICE, describing meetings between parents and ICE officers regarding whether their children would remain in custody with the parent or be turned over to a sponsor in the US.
Families detained in all three ICE detention facilities -- Berks in Pennsylvania, South Texas (Dilley) and Karnes County Family Residential Centers in Texas -- shared similar stories. Children at the facilities range from 1 year old to 17 years old, according to lawyers and advocates who provide legal assistance.
"The Administration must stop using this public health crisis as a means for implementing unlawful and inhumane immigration policies. In these extraordinary times, human suffering need not be compounded by locking up families or instilling fear in the hearts of migrant parents," read the letter, directed to acting Homeland Security Secretary Chad Wolf and acting Immigration and Customs Enforcement Director Matt Albence.
ICE denied instituting a binary choice or separating any parents from their children "pursuant to 'binary choice.'"