ST. LOUIS – St. Louis jails must stop holding inmates just because they can't afford to pay bail, a federal judge ruled.

U.S. District Judge Audrey Fleissig's ruling Tuesday gives city officials one week to hold detention hearings for inmates already behind bars – potentially hundreds of people. The ruling also states that moving ahead, anyone arrested must have a hearing within 48 hours.

A lawsuit filed in January alleged that people arrested and detained typically don't get a hearing on release conditions until obtaining a lawyer. For those who can't afford an attorney, appointment of a public defender can take months. The lawsuit said those too poor to hire an attorney linger behind bars, away from their families and often losing their jobs.

The ruling still allows inmates to be held if they pose a danger or there's no other way to ensure they show up for court.

Fleissig wrote that the St. Louis practices on cash bail "fall short of constitutional standards in that Defendants fail to articulate any governmental interest in detaining indigent defendants while releasing moneyed defendants facing the same charges, without any consideration of individual factors."

City Counselor Julian Bush said Wednesday that the city may seek a stay of Fleissig's order. Bush said it is state court judges, not anyone involved with the city, who set bail. He worried that Fleissig's ruling could mean the release of potentially dangerous criminals.

"We take no position as to whether the judges are right or whether the plaintiffs are right," Bush said. "We just want to make sure the people of the city of St. Louis are not hurt in the crossfire."

The lawsuit was brought by several advocacy law organizations, including St. Louis-based ArchCity Defenders. Executive Director Blake Strode called the ruling "a critical first step in ending the current status quo of wealth-based detention."

"At this very moment, there are hundreds of people detained in the City of St. Louis merely because of their poverty," Strode said in a statement.

Other cities also have wrestled with the issue.

In March, the American Civil Liberties Union of Pennsylvania and several groups seeking changes to the criminal justice system sued Philadelphia court magistrates, claiming the cash bail system unfairly targets poor people of color. The lawsuit alleges the magistrates rely too heavily on cash bail and are effectively punishing people for being poor.

The ACLU has filed other lawsuits challenging unfair bail practices in Alabama, Texas, Florida, Colorado, Georgia, North Carolina, Mississippi, New York and California.

Prosecutors in some places also have instituted new policies to change the cash bail system. Among them is St. Louis Circuit Attorney Kim Gardner, who announced in January that her office would stop requesting cash bail for many low-level felonies, such as drug possession.