A federal judge has rejected motions to release or transfer two sex offenders while raising serious doubts about the constitutionality of the Minnesota Sex Offender Program (MSOP).

In a ruling Monday, U.S. District Judge Donovan Frank denied a motion for the immediate release of Eric Terhaar, 24, who has spent the past five years under state confinement for acts he committed as a juvenile. Frank also denied a motion to immediately transfer Rhonda Bailey, 48, the only woman ever committed as a sex offender in Minnesota, to a separate women's facility.

But while the ruling is a setback for individual sex offenders seeking short-term relief, Frank indicated there may be a deeper, systemic failure with MSOP and Minnesota's current system of locking away sex offenders indefinitely in treatment centers after they have completed their prison sentences.

Frank quoted a state task force report that said there is "broad consensus that the current system of civil commitment of sex offenders in Minnesota captures too many people and keeps too many of them too long," as well as a critical report in 2011 by the state legislative auditor.

"Both reports indicate there may be systemic problems with MSOP and its application of the commitment statutes," Judge Frank wrote. In a ruling earlier this year, Frank had referred to the sex offender program as "clearly broken" and in need of immediate reform.

The judge's ruling indicates he is more interested in the systemic concerns of the program than in ruling on individual cases, said Eric Janus, dean of the William Mitchell College of Law in St. Paul and author of a book on sex offender civil commitment.

"The systemic perspective is much more threatening to the state," Janus said. "It indicates that he's aiming for a decision on the constitutionality of the system as a whole, and not whether this person or that person is wrongly committed."

The judge has moved to expedite the class-action case and set it for a trial later this year, which means that a final ruling on the constitutionality of the sex offender program could be in the offing. About 690 sex offenders are being held indefinitely at high-security treatment centers in Moose Lake and St. Peter. Only two people have ever been provisionally discharged from the program in its 19-year history.

"We're pleased with the court's order because the court recognizes that these two individuals are being held by MSOP in conditions that call into question whether that confinement is constitutional," said Dan Gustafson, an attorney for Terhaar, Bailey and a class of sex offenders suing the state over their indefinite confinement.

The Terhaar case, in particular, had been viewed as a flash point in the constitutional debate.

The four court-appointed experts argued that Terhaar's early sexual offenses as a juvenile were influenced by his own sexual victimization, and that his behavior was likely exacerbated by his attention deficit hyperactivity disorder (ADHD) and untreated trauma. The experts also noted that most juveniles who act out sexually do not continue to offend as adults. "There is little evidence to suggest that Mr. Terhaar is a dangerous sexual offender who poses a significant risk to public safety," the experts wrote.

Even though Judge Frank denied a motion to release Terhaar on narrow legal grounds, he acknowledged recent state efforts to accelerate Terhaar's treatment and possible discharge. At a federal court hearing last month, MSOP's executive director said the state could petition to release Terhaar, with certain conditions, within months after he is moved to a less-secure facility. The state also has moved to consult with experts to determine an appropriate placement and treatment for Bailey.

"It is obvious that but for this litigation, Terhaar … would likely have languished for years in the prisonlike environment of MSOP-Moose Lake without any realistic hope of gaining his freedom," Frank wrote. "And of course it is of great concern to the court that this may not be an aberrant case of system failure but is symptomatic of a larger systemic problem of constitutional concern."

Twitter: @chrisserres