In San Francisco, the city attorney, Dennis Herrera, and the state attorney general at the time, Kamala Harris, declined to defend against the lawsuit, saying the bail system was unfair. In Houston the district attorney, Kim Ogg, weighed in with an impassioned friend-of-the-court brief, writing, “It makes no sense to spend public funds to house misdemeanor offenders in a high-security penal facility when the crimes themselves may not merit jail time.” Like Sheriff Gonzalez, Ms. Ogg is newly elected.

Those left to defend the system have had a lonely uphill fight. James Munisteri, a private lawyer hired by Harris County, faced calls for his removal after he told the court at an earlier hearing that misdemeanor defendants might be in jail not because they couldn’t afford to post bond, but because they “want” to be there. “If it’s a cold week,” he added.

The judge, Lee H. Rosenthal of Federal District Court, was skeptical of that contention, calling it “uncomfortably reminiscent of the historical argument that used to be made that people enjoyed slavery, because they were afraid of the alternative.”

The case was filed last May on behalf of Maranda Lynn ODonnell, who was arrested on charges of driving with an invalid license. She spent over two days in jail because she couldn’t afford to pay her $2,500 bond. Civil Rights Corps, the organization whose director, Alec Karakatsanis, has led the legal attacks on unaffordable bail across the country, joined with the Texas Fair Defense Project, a nonprofit legal defense organization, and Susman Godfrey, a law firm, to bring the case.

So far, the county has spent $1.2 million on outside lawyers to defend itself.

The Supreme Court has held that liberty before trial should be the norm, and that bail conditions must be set based on the individual’s circumstances. Bail is not meant to be punitive; it is intended simply to ensure that defendants return to court. Texas law requires consideration of “the ability to make bail.”

But the videos made it clear that bail was routinely set with no inquiry into defendants’ ability to pay — or with the full knowledge that they could not. When suspects are first booked, their bail is set using a fee schedule based on the charge and on criminal history. At the probable cause hearing, where typically no lawyer is present, the hearing officer can raise or lower the bond, or grant a personal bond, which allows the defendant to go without an upfront payment.

The county argued that it began reforming its pretrial release system before the lawsuit was filed. It recently issued guidelines recommending the use of personal bonds for people accused of 12 low-level misdemeanors. Beginning on July 1, it plans to make public defenders available at the probable cause hearing. The bail fee schedule will disappear, to be replaced by a risk assessment, a more sophisticated method of determining an arrestee’s likelihood of fleeing or of committing a new crime.