Since the 1990s, when Minnesota began involuntarily committing sex offenders deemed “sexually dangerous” or “sexual psychopathic personalities” to the treatment program after they finished prison terms, no one has been found to have improved enough to be fully discharged. State records show that only three people have been released with tight restrictions.

“The stark reality is that there is something very wrong with this state’s method of dealing with sex offenders in a program that has never fully discharged anyone committed to its detention facilities in Moose Lake and St. Peter since its inception in 1994,” the judge wrote, adding that given the structure of the program and its history, “no one has any realistic hope of ever getting out of this ‘civil’ detention.”

The judge’s finding in the class-action lawsuit, filed in 2011 by 14 people who were being held, leaves state officials and lawmakers to try to come up with suitable repairs to the program during a second phase of the case this summer. The ruling does not mean that the centers, which resemble prisons in many ways, will immediately close.

Gov. Mark Dayton, a Democrat, defended the program, and suggested that further legal action is possible. “We continue to believe that both the Minnesota Sex Offender Program and the civil commitment statute are constitutional,” he said.

Along with the federal government, Minnesota and 19 other states have civil commitment laws that allow hundreds of pedophiles, rapists and other sexual offenders to be treated and detained beyond their criminal sentences, usually in special treatment centers. A series of shocking and highly publicized crimes in the 1980s and 1990s led states to write the current set of laws permitting commitment for such offenders.