SAN ANTONIO (AP) — A group of immigrant rights lawyers say that detention of women and children caught crossing the U.S.-Mexico border illegally is lengthy and unsafe, challenging the government's claims that immigrant families are held only briefly and that their detention doesn't violate a longstanding ban.

In a filing Thursday to California U.S. District Judge Dolly Gee, the lawyers also said the health and safety of immigrant children is being jeopardized by "hopelessly inadequate" medical and psychological care at the detention facilities where they say the families are routinely kept for more than a month.

The government has said the mothers and children are held for just weeks while their asylum claims are processed. But the lawyers said the families are held for longer because immigration officials delay the screening and processing of asylum claims, routinely hinder access to legal help and because bonds are too high for the women to pay to secure their release.

The immigration lawyers cited extensive complaints about health care at the facilities, including untreated or unrecognized ailments that resulted in children being hospitalized, lack of medicines, erroneous vaccinations and extremely long waits.

"Children are placed at risk every day," the lawyers said in the filing.

The government poured millions of dollars into two large detention centers in Texas for women and children after tens of thousands of immigrant families, mostly mothers with children from Central America, crossed the Rio Grande into the U.S. last summer. A third, smaller facility, is in Pennsylvania.

All are overseen by U.S. Immigration and Customs Enforcement but managed by private prison operators. They currently hold some 1,400 people, down from more than 2,000 earlier this summer.

Homeland Security and ICE officials have said they aim to release families as soon as they pass interviews that are the first hurdle to being granted asylum. In recent weeks, more women have been fitted with ankle monitors when released from detention, sometimes under pressure and after bonds have been set, the lawyers said in the filing.

In late July, Gee ruled that Homeland Security should release all children from the centers "without unnecessary delay," along with any mothers not deemed a flight or national security risk. Many have petitioned for asylum after fleeing gang and domestic violence back home.

Last week, Homeland Security attorneys asked the judge to reconsider her ruling, saying detention times have been shortened and that further limiting family detention could spark another surge in immigrants from Central America.

The lawyers asked the judge to implement her earlier ruling calling for the quick release of detained women and children. Peter Schey, one of the lead attorneys and executive director of the Center for Human Rights and Constitutional Law, called the policy of detaining children inhumane, adding that Homeland Security Secretary Jeh Johnson should be "ashamed of himself" for "detaining young children in adult prisons that are unsafe."

Gee ruled in July that detaining children violates parts of a 1997 settlement covering all children in federal immigration custody, and that the facilities were not properly licensed to care for children.

Between Sept. 2013 and Oct. 2014, some 68,000 members of migrating families were caught at the border, according to U.S. Customs and Border Protection. Between last October and June of this year, less than 27,000 have been apprehended, which authorities say is due to better enforcement in the U.S. and Mexico.