The Obama administration has less than two weeks to hash out an agreement to salvage its practice of undocumented migrant family detentions, borne of last summer’s crisis at the southern U.S. border. If the government can’t pull together a deal quickly, a pending court order could end the controversial policy now facing increased legal pressure.

Last month, U.S. District Judge Dolly Gee of California issued a draft court order in a lawsuit over family detentions, saying the policy violated a 1997 settlement prohibiting the detention of unaccompanied immigrant minors. The McClatchy news service first obtained the memos and reported on it in late April. Gee gave attorneys 30 days to work out an agreement over family detentions, but if they are unable to reach one, she will officially enter the draft court order after May 24. That could end the Obama administration’s policy.

Immigrants’ rights advocates have long pushed for an end to the practice, which they say treats asylum seekers and refugees fleeing violence in Central America as criminals. But many are still wary of what happens next. “We’re very hopeful that it will be sort of an end to family detention,” said Mohammad Abdollahi, advocacy director at Raices, a Texas nonprofit providing legal assistance to detained migrant families. “But at the same time the next step is: What is the government going to come up with next to find a way around the court order?”

The judge ordered officials from the Obama administration and attorneys for the plaintiffs to not discuss the case publicly while the lawsuit is pending.

The Department of Homeland Security faces a barrage of legal challenges to its family detention facilities, which it set up in the wake of the surge of migrants at the southern U.S. border last year. Homeland Security Secretary Jeh Johnson repeatedly said the detentions would deter others looking to cross into the U.S. illegally. Earlier this year, a federal judge ruled that the deterrence justification was likely unlawful and placed a preliminary injunction on the practice of detaining families without bond.

But some families have been held in detention with bonds as high as $7,500, according to some reports. Meanwhile, advocates have been highlighting allegations of abuse against the mothers and children detained in the three remaining active family detention centers. Last fall a group of women at the family detention facility in Karnes County, Texas -- one of the three active family detention centers in the U.S. -- filed a lawsuit alleging sexual abuse by staff there. In February, the Department of Homeland Security’s inspector general issued a report saying it found no evidence to substantiate those claims.

But accusations of mistreatment still abound. “The experience of mothers and children in the detention centers has been absolutely devastating,” Abdollahi said. Children as young as four and five have experienced rapid weight loss and exhibited signs of depression from their time in the facilities, and the staff has no expertise as child-care specialists, he said. “It’s devastating in terms of child abuse and negligence and how it’s being okayed and swept under the rug.” In April, a group of detainees at Karnes launched a weeklong hunger strike to protest the facility’s conditions.

“We have come to this country with our children in search of refuge, and they are treating us like criminals,” the group wrote in a letter in Spanish to explain why they were launching the strike.

Without the family detention centers, migrant families could simply get released into the U.S. on their own recognizance with scheduled immigration hearings to determine whether they may stay in the country. That's the existing system for unaccompanied minors who are caught at the border, since U.S. law prohibits them from being put into detention facilities alone. Other immigrants are put into alternative-to-detention programs, which require regular check-ins with immigration officials in the weeks leading up to their immigration hearings. But this week’s negotiations between the Obama administration and plaintiffs’ attorneys may come up with a different solution altogether. 

It was only six years ago that migrant family detentions already appeared to be coming to an end. In 2009 the Obama administration closed the T. Don Hutto detention facility in Texas, a family detention center that attracted a swarm of criticism for putting families with young children in what critics said were prison-like conditions. Hutto’s closure marked a widespread moratorium on family detentions nationwide, with the exception of one small facility in Leesport, Pennsylvania.

But the administration revived family detentions last summer to deal with the overwhelming number of migrants crossing illegally into the United States through the southern border. While tens of thousands of the migrants were unaccompanied children who were placed into temporary shelters and then released to family members in the country to await immigration hearings, the administration increasingly began detaining family units – mainly mothers and children from the so-called Northern Triangle countries of Guatemala, El Salvador and Honduras.

Since then it’s opened three family detention centers -- in Artesia, New Mexico, Karnes County, Texas and Dilley, Texas -- although it closed the Artesia center late last year as the facility faced a firestorm of allegations of mistreatment of detainees there. The Dilley facility, the newest family detention center, is the largest of all of them with a capacity to hold 2,400 migrants. The Karnes County facility holds around 600 beds for migrant detainees but was approved for an expansion in December to double in capacity. Most of the facilities are run by private prison operators, including Corrections Corporation of America and GEO Group, two of the largest private prison companies in the country. 

The outcry against family detentions has grown louder in recent months, and presidential hopeful Hillary Clinton recently criticized the policy. “I don’t think we should put children and vulnerable people into big detention facilities because I think they’re at risk,” she said last week in Nevada.

Meanwhile, the U.S. saw a stark decline in the number of Central American migrants crossing the southern border this year. But much of that decline came from Mexico’s increased enforcement against illegal immigration, as Mexican officials have dramatically ramped up deportations and detentions of Central American migrants caught within its own borders.