Texas is close to passing a law that will help preserve the federal government’s policy of detaining immigrant families by licensing detention centres as childcare facilities.

The move would allow the government to sidestep a 2015 federal court order that immigrant children must not be held in unlicensed detention centres for more than a few days.

Critics fear it will pave the way for asylum-seeking mothers and children to be kept in traumatising, prison-like conditions for weeks and months while their claims are assessed.

Texas is home to two of the country’s three family detention centres – the other is in Pennsylvania. With their future in doubt because of the court’s 2015 ruling, the state’s department of family and protective services decided to license them a year ago.

A judge in Austin blocked the move amid concerns that the agency was overstepping its remit and that the nature of the facilities means they should not qualify as childcare centres.

Some detainees have alleged they endured inadequate medical care, poor conditions and sexual abuse, while the American Academy of Pediatrics is among the groups to have expressed concern about the health impacts of detaining children and recommends only “limited exposure of any child to current Department of Homeland Security facilities”.

But Texas’s Republican-dominated legislature is now poised to loosen the regulatory requirements so that the agency can license the centres.

“[Texas has] just taken a step to help private prison corporations circumvent these court rulings that are meant to protect children, and we’re greatly disappointed,” said Laura Guerra-Cardus of the Children’s Defense Fund of Texas, an advocacy group.

“They are going through the proper processes and our reaction is apparently to jail them, to detain women and children despite the knowledge that it is causing further harm to these already traumatised children.”

The facilities, Dilley and Karnes, are near San Antonio and together can hold more than 3,000 people. Run by private companies, they opened in 2014 as part of the Obama administration’s response to the surge of young people fleeing violence and hardship in central America and crossing at the Texas-Mexico border to seek asylum.

“They’re coming because they’ve been abused, they’ve been neglected,” said Sylvia Garcia, a Democratic state senator, during a debate before the bill passed in a vote along party lines on Tuesday. “And now, to add insult to injury, we’re going to put them in ‘baby jails’?”

After final passage from the state senate, the measure, SB 1018, must be approved by the house and signed by the governor before becoming law. Its advocates argue that the licensing process will allow for more oversight of the centres, helping to correct deficiencies.

Bryan Hughes, a Republican state senator who is the bill’s co-author, told the chamber that“we want to make sure that if they’re in Texas they’re meeting Texas standards”.

Critics are unconvinced that Texas’s already stretched child welfare system will provide meaningful regulation of the buildings and point out the bill allows the state agency to “exempt a family residential centre from any minimum standard or rule applicable to a general residential operation”.

Hughes told senators that this clause would make it easier for operators to house families together, rather than acting as an invitation to lower the quality of care.

Immigrant advocates contend that asylum-seekers should not be detained, but released to stay with relatives, friends or supportive organisations while their cases wind their way through the legal process.

A state representative who introduced another version of the bill told the Associated Press last month that it came from GEO Group, the company that runs Karnes. “I’ve known the lady who’s their lobbyist for a long time. That’s where the legislation came from,” John Raney said.