SAN ANTONIO — It had been six months since Maria fled for the U.S.

She spent the first two weeks running from her tiny hometown in southern Guatemala, where she said gangs had threatened to kill her and her 7-year-old son, Jerson. After traveling through Mexico, they requested asylum at the U.S. border.

They were separated for the next two months, with Maria detained at an adult detention center in Arizona and Jerson sent to a shelter in New York. Given the choice to reunite with her son in detention or be deported without him, Maria chose the former.

So for the last four months, they were locked up together at a family detention center in Dilley — the largest facility of its kind in the country – about an hour southwest of San Antonio.

There, she watched and worried as her son stopped eating, stopped going outside, and stopped saying much at all, Maria said. Jerson would wake up screaming at night. He fell into a sluggish state so often during the day that other mothers had to help carry him around, she said.

“Instead of him being killed quickly there,” she said, “they were killing him slowly here.”

On Nov. 30, their nightmare finally ended at Terminal B of San Antonio’s airport. That's where Maria and six other mothers who had been held at Dilley — the last of those that U.S. officials had separated and then detained — were released. From there, they boarded planes to join family across the country.

“As a mother, you feel guilty to see children suffer so much,” said Maria, who declined to give her last name for fear of retaliation.

A longstanding court settlement normally prevents the government from keeping migrant children at Dilley and another facility in Karnes County for more than 20 days because neither is licensed by a state or local government.

But a recent Texas court ruling opened the door for state officials to issue licenses to those family detention centers, meaning that migrant families could be held there for months on end. In other words, long stays like the one for Maria — who voluntarily waived protections in order to be reunited with Jerson — could be the rule, not the exception.

Some top Texas politicians have applauded the ruling, saying it would allow the state to provide greater oversight and keep migrant children safe. But immigration lawyers and advocates say those detention centers are no place for kids.

“If you’re a mother or a father, imagine raising your child in jail,” said Shay Fluharty, the managing attorney at the Dilley Pro Bono Project, which had worked to release mothers like Maria. “That’s what it’s like.”

Together, Dilley and Karnes have about 3,500 beds, comprising the vast majority of space available to the federal government for family detention. Advocates have alleged that the facilities lack adequate education, medical care and mental health services. Earlier this year, a toddler from Guatemala named Mariee Juarez died after developing an infection and respiratory symptoms inside Dilley.

Adelina Pruneda, a spokesperson for Immigration and Customs Enforcement, said that family residential centers “operate in an open environment” that includes medical care, play rooms, social workers, educational services and access to lawyers.

CoreCivic, the company that manages the Dilley facility, declined to comment.

Appeals court ruling could mean big changes

At the center of both Maria’s case and the recent decision is a longstanding court settlement known as the Flores agreement, which says the government can only hold migrant children indefinitely in nonsecure, licensed facilities. In any other facility, children must be released after 20 days.

The Obama administration opened Dilley and Karnes in 2014 in response to a surge in Central American migration. Migrant families seeking asylum would be detained there for weeks as officials sought to process their claims and deport them as quickly as possible.

But after legal challenges, a federal judge ruled in 2016 that the Flores settlement still applied to kids being detained with their parents. Because these facilities were unlicensed, the judge said, keeping children there for long periods of time violated the agreement.

Texas tried to get around that ruling by attempting to license Karnes and Dilley as childcare facilities. An Austin advocacy group, Grassroots Leadership, and several detained mothers successfully sued in 2016 to block the facilities from being licensed.

That lawsuit was overturned on Nov. 28 by the Austin-based 3rd Court of Appeals in Austin, which said that the group and the detained mothers did not have legal standing to sue — thus opening the door for Texas to license Dilley and Karnes.

Bob Libal, executive director of Grassroots Leadership, said he feared that the ruling could lead to “long-term psychological and physical harm on children” detained there.

“Family detention centers are not childcare facilities,” he said. “The sole reason that the state wanted to license these private prisons as childcare facilities was to prolong the detention of children.”

Attorney General Ken Paxton applauded the ruling, saying it would allow the state to regulate the centers and ensure the safety and well-being of the children there.

“Texas strives to keep children as safe as possible by providing independent oversight over the family residential centers through its child-care licensing program,” he said.

Still, it is unclear if either facility is “nonsecure,” a key requirement necessary to detain children there indefinitely under Flores. Representatives for ICE and the two for-profit companies that manage Dilley and Karnes did not respond to questions about what would happen if someone detained there attempted to leave.

After separation, four months of detention

Because of the 20-day limitation imposed by the Flores settlement, immigrant families detained at Karnes or Dilley are often released with an ankle monitor and an order to appear in court.

This practice is what Trump and other federal officials have denounced as “catch and release.” And it’s what they used to partially justify why they separated children from their parents earlier this year — a policy Trump later ended after massive public outcry.

Amid a scramble to reunite those families this summer, a federal judge in San Diego ruled that the government could give some parents a choice: Either remain separated, or waive your child's Flores rights and be detained together indefinitely.

That’s the choice that was given to Maria and the 37 other families who had been held for extended periods in Dilley from July through November, as immigration lawyers and the government negotiated their futures.

“With everything that was happening in my country, with the threats we were facing,” Maria said, “we had to stay here. But I never thought it would end up like this.”

It was a choice that came at a cost for the mothers.

Juan, a 13-year-old from Guatemala, stopped eating breakfast and dinner most days and got frequent headaches while he was detained in Dilley, his mother said.

“He would keep telling me, ‘Mami, when are we going to leave? Mami, I can’t be here any longer,” said his mother, who is also named Maria. “He got really desperate and depressed inside.”

A doctor inside the facility would offer Tylenol for Juan’s headaches, but offered no other help, she said.

Since the end of family separation, the Trump administration has made several moves to overturn the Flores settlement. In July, a federal judge in Los Angeles rejected a request from the Justice Department to detain immigrant children indefinitely.

More recently, federal officials have attempted to pull out of the Flores agreement and institute federal regulations to allow the government to detain migrant families indefinitely. Their move will almost definitely be challenged in court.

But the Texas appellate ruling last week may have given the Trump administration the ability to detain thousands of families while still meeting the stipulations of the Flores agreement.

To Maria, waiting for her plane at Terminal B, that possibility is terrifying.

“Based on lived experience, being there is harmful for all families,” she said. “It hurts the kids, psychologically and emotionally.”

Her son put it more simply.

At Dilley, “I didn’t play,” he said, “because I felt sad. Because I wanted to leave.”