A federal judge ruled Friday that the District government violated the rights of hundreds of D.C. jail inmates by subjecting them to unwarranted strip searches and then detaining them too long after they had received orders of release.

In a 49-page opinion in a class-action lawsuit brought by former D.C. jail inmates, U.S. District Judge Royce C. Lamberth also declared unconstitutional a District law preventing the release of inmates after 10 p.m. On the advice of its attorneys, the D.C. government had stopped enforcing that statute in 2009, Lamberth wrote.

Lamberth called the D.C. government’s actions, particularly in the months after a 2005 settlement in a similar lawsuit, “conscience-shocking” because officials had taken no concrete steps to fix well-known problems with processing inmates upon returning from court.

William Clairborne, an attorney for the inmates, said he was “very pleased” by the ruling; a spokesman for the D.C. Attorney General’s office said lawyers were reviewing the opinion and declined to comment further.

During a 16-month period ending in late 2006, Lamberth found that the D.C. government had improperly held more than 3,000 inmates for as long as several days after they had been acquitted or had obtained orders dismissing charges against them. All those inmates were subjected to strip searches upon return to the jail, Lamberth wrote.

In the following months, the jail appears to have improved its operations, Lamberth wrote, and he will allow a jury to decide whether the D.C. government violated the rights of inmates from early 2007 through February 2008. Perhaps as many as 2,000 inmates spent too long in jail during that period, Lamberth wrote.

By 2008, Lamberth wrote, the D.C. government had sufficiently fixed the problem. Fewer than 100 inmates were held for too long in 2010, the judge wrote.

Lamberth will rule on damages at a future date.