A federal judge issued a temporary restraining order Friday seeking to reduce overcrowded and filthy conditions in the nation's largest county jail system.

The order came in response to an American Civil Liberties Union request that Sheriff Lee Baca and county supervisors make immediate improvements to what the organization called "almost unspeakable conditions" at county jails.

U.S. District Judge Dean D. Pregerson said in a 10-page order the county cannot hold more than 20 inmates in a holding cell "without first exhausting every other means" and that an inmate cannot be held in the county's Inmate Reception Center for more than 24 hours.

"The court has no desire to inject itself in the management of the jail," Pregerson wrote, but added that "inmates, particularly pretrial detainees who are imbued with the presumption of innocence, deserve better than to be housed in a system which has defaulted to the lowest permissible standard of care."

Pregerson also ordered that inmates cannot be held in cells that are not "in a clean and sanitary condition, including access to a functioning toilet, potable drinking water and clean water to wash."

Sheriff's spokesman Steve Whitmore said the department had been working to address concerns even before Friday's order.

"We share the court's concern, and we are working every day to do our jobs better," Whitmore said.

Since mid-September, hundreds of men were detained for up to four days at the jail's Inmate Reception Center in dirty, crowded conditions, the ACLU alleged in court documents.

Up to 60 men were kept in cells meant for 20 people as they awaited transfer to a permanent jail, according to the ACLU. Some had to take turns standing for hours at a time so that others could have room to sit or sleep on the floor.

"This order means that the nightmarish conditions in our jails cannot be maintained," Mark Rosenbaum, the ACLU's Southern California legal director, said in a statement. "Inmates should not be stripped of the bare requisites of dignity and decency."

Pregerson ordered a hearing Dec. 11 on the restraining order.