With tens of thousands of migrants flooding into Europe in recent months, it's easy to forget that the US faced its own refugee crisis last summer when scores of children and mothers bolted from Central America amid heightened gang and drug violence. Desperate for a safe haven, the families mounted buses and trains through Mexico and then poured across the Texas border, seeking political asylum.

To combat the influx, the Department of Homeland Security (DHS) launched an "aggressive deterrence" strategy last July designed to discourage more people from coming. The solution, DHS Secretary Jeh Johnson announced, was to lock up Central American moms and kids as they fought their asylum cases in court. Previously, DHS did not detain such families, but rather allowed them to pay a small bond as an assurance they would show up to their court dates.

The new DHS strategy spawned a massive, long-term family detention system for Central American asylum seekers in the US. The agency contracted the nation's two biggest private prison companies to open facilities in southern Texas that hold about 3,000 people combined and cost taxpayers hundreds of millions of dollars to operate. Many families have spent seven or eight months in detention while awaiting their day in court.

Guards preside over the remote lock-down facilities, where detainees have little chance for contact with the outside world. Distressed mothers have staged multiple hunger strikes to protest conditions, one detainee attempted suicide, and lawyers have alleged that guards have sexually abused women. Human rights groups say the experience causes lasting trauma for families.

"Every single solitary right a parent has is taken away in detention — a mother can't discipline her child, feed her child, choose her child's medical care or education," Linda Brandmiller, an immigration attorney who has represented more than 100 mothers at Karnes, said. "The kids ask their mothers every day, 'Why are we here?' and they can't answer that fundamental question. My mothers have reported that their children's personalities have changed while detained."

'Every single solitary right a parent has is taken away in detention.'

Immigrant advocates and some members of Congress have fought to close the facilities, arguing that detention is unnecessary. Earlier this summer, a federal judge in California ruled that the DHS family detention policy is illegal because it violates basic standards of care for children.

But Judge Dolly Gee's order — a response to a lawsuit filed against DHS by lawyers for the Center for Human Rights and Constitutional Law — was not strong enough to shutter the detention centers, multiple experts told VICE News.

Gee's ruling requires DHS to stop detaining children for periods longer than five days — except when there are "extenuating circumstances," like another surge of illegal border crossers. In that case, kids may be held for up to 20 days. DHS has until October 23 to begin complying with the judge's order.

Barbara Hines, co-director of the Immigration Clinic at University of Texas Law School, said Gee's decision still "gives the government wiggle room" to continue incarcerating families.

"I'm disappointed in the decision because it gives the government an out, in the sense that the judge does mention that there is an escape clause," Hines said of the "extenuating circumstances" caveat. "When Gee's decision first came out people were saying, 'It's fabulous. It's a major victory.' Don't get me wrong, but it could have been much bigger."

Gee's ruling does prevent DHS from detaining families for months at a time as it has earlier this year, Hines noted. But she predicted that the two large Texas facilities — Karnes Residential Center and South Texas Residential Center — would remain fully operational, costing the US government vast sums of money. DHS paid private prison companies Corrections Corporation of America (CCA) and the GEO Group at least $362 million to run the two facilities over the last year.

The two corporations have spent millions of dollars lobbying the federal government to expand immigrant detention and prevent immigration reforms that would harm their businesses, an April report by the non-profit Grassroots Leadership found.

"The prison companies are very powerful — they have a very powerful lobby and make a lot of money. Once the government start programs like this and builds these facilities it's much harder to shut them down," Hines said. "There's no sign DHS is trying to ramp them down."

In fact, CCA and GEO appear to be moving quickly to comply with Gee's order. Gee ruled that the law requires facilities housing children to be licensed as residential childcare facilities by child welfare providers, which Karnes and Dilley are not. Both CCA and GEO have now applied for residential childcare licenses with the state of Texas.

In response to Gee's ruling, the Texas Health and Human Services Commission passed an "emergency rule" on September 2 that allows the Department of Family Protection Services to license family residential facilities, agency spokesman Patrick Crimmins said.

"The court highlighted a gap in oversight in these facilities and we were trying to close that gap," Crimmins said. "There are hundreds of pages of minimum standards they now have to comply with, like smoke detectors, the size of facility, the ratio of employees to residents, the number of toilets and sinks and bathrooms. It's the same kind of license you get for an emergency shelter or a foster home."

'Once the government start programs like this and builds these facilities, it's much harder to shut them down.'

But Brandmiller questioned the state's ability to "fast track" a process that allows Karnes and Dilley to be licensed. The childcare licenses typically apply to residences for unaccompanied minors, not for minors with their parents, she told VICE News.

GEO spokesman Pablo Paez referred questions to DHS, and a spokesman for CCA did not return repeated requests for comment. DHS spokeswoman Marsha Catron said the agency had no plans to close the facilities, and said they have already made "significant changes," including detaining families for shorter periods of time.

"Recognizing the sensitive and unique nature of detaining families, we have made significant changes to the family residential facilities," Catron said in an emailed statement. "Of note, we are transitioning these facilities into short-term processing centers where individuals who claim fear of return to their countries can be interviewed for asylum and other humanitarian protections."

This year, the number of Central American border crossers has plummeted — not because fewer people are trying to flee gang violence, but because the US has pushed Mexico to tighten its southern border. Mexico is now deporting about twice the number of migrants as it did last year.

Family detention won't disappear overnight, but Gee's decision and increasing political pressure could eventually prompt DHS to significantly curtail the practice, said Muzzafar Chisti, director of the Migration Policy Institute's office at NYU School of Law.

Chisti said Gee's ruling could prove even more significant since it occurred during an election year. Just last week, for instance, Democratic candidate Bernie Sanders presented a plan to ban private prisons.

"For the first time in a long time the federal government is faced with the prospect of having to alter the family detention system in a fundamental way," Chisti said. "The legal boost has given a whole new weight to the political pressure."