The judge, Donovan W. Frank, of Federal District Court in St. Paul, on Thursday ordered the state to promptly conduct independent risk and treatment assessments on everyone being detained, to seek releases or ease restrictions in appropriate cases, and to begin conducting annual assessments to determine whether everyone here still meets the legal requirements for civil commitment.

Minnesota is not alone in revisiting its policies. In Missouri, a federal judge last month found that state’s program violated people’s right to due process, potentially imposing “lifetime detention on individuals who have completed their prison sentences and who no longer pose a danger to the public, no matter how heinous their past conduct.” Of about 250 people held since Missouri began committing people in 1999, state officials say seven have been granted what the state considers release with court-ordered restrictions, though some of those men remain in a group-home-like setting behind razor wire at a state facility.

In Texas, which previously had a unique outpatient method for treating sex offenders civilly committed after their prison sentences, the Republican-dominated State Legislature this year revamped the program after a Houston Chronicle investigation found that none of the hundreds committed to the program had ever graduated from it. The investigation also found that nearly half of the men detained for treatment while living in halfway houses and other facilities were actually sent back to prison for breaking the program’s rules.

“My sense was that we had to make changes or a federal court is going to strike down the whole program, and we need this program — some of these people would scare the hell out of you,” said State Senator John Whitmire, a Democrat who helped push through the overhaul, which included opening a former prison in remote Littlefield to house the detainees. “The way it was, it just looked like incarceration with double jeopardy,” Mr. Whitmire said. “This at least holds out a pathway to graduate.”

Civil commitment gained support in the 1990s amid reports of heinous sex crimes by repeat offenders. Today, 20 states, along with the federal government, detain some sex criminals for treatment beyond their prison time. But not all have been as sharply criticized as Minnesota’s program. In Wisconsin, 118 offenders have been fully discharged from commitment since 1994, and about 135 people have been given supervised release, according to Judge Frank. New York had sent home 30 people and moved 64 people out of secure facilities for the civilly committed and into strict supervision and treatment, Judge Frank wrote.