A federal appeals court in St. Louis has declared that Minnesota’s sex offender treatment program is constitutional — handing a major victory to the state but potentially derailing long-awaited reforms to its system of indefinite detention for sex offenders.

In a decision released Tuesday, a three-judge panel of the Eighth Circuit Court of Appeals reversed a lower-court ruling and found that Minnesota’s system of committing sex offenders beyond their prison terms serves a “legitimate interest” in protecting citizens from dangerous sexual predators.

The ruling is a major setback for civil rights attorneys and a host of lawmakers who have spent much of the past five years pressing for reforms that would put offenders on a faster path toward release from the Minnesota Sex Offender Program (MSOP). The appellate panel essentially has given Minnesota’s program a clean bill of health, relieving immediate pressure on state officials to make major reforms to a program that has long been criticized as inhumane.

A class of sex offenders sued the state in 2011, arguing during a prolonged trial that Minnesota’s system violated their due-process rights under the U.S. Constitution by depriving them of access to the courts and other basic safeguards found in the criminal justice system.

But after reviewing the program and state law, the appeals court sided with the state, concluding that Minnesota provided adequate constitutional protections, including the right to petition for release.

“We conclude that the class plaintiffs have failed to demonstrate that any of the … arguable shortcomings in the MSOP were egregious, malicious, or sadistic as is necessary to meet the conscience-shocking standard,” the Eighth Circuit panel ruled.

721 Number confined in Minnesota’s sex offender program 89 Nearing approval for conditional release $89.7 million Annual budget for fiscal year, 2017 Estimated annual cost per MSOP client $124,000 Source: Minnesota Department of Human Services

Reached Tuesday, the plaintiffs’ lead attorney said the appellate judges used too narrow a standard for reviewing his clients’ due-process claims, and said he is considering an appeal to the U.S. Supreme Court, which must be filed within 90 days.

“Justice was not done today,” said attorney Dan Gustafson. “We’re still considering what we are going to do, but, as Gov. Dayton said the other day, we are not going quietly into the night.”

Among detainees at the MSOP’s campus in St. Peter, Tuesday’s ruling was met with “a mix of despair and anxiety,” said Benjamin Alverson, 41, a sex offender who has been at the MSOP for more than 11 years. Word of the ruling spread through the campus just before noon as clients were heading to the cafeteria for lunch, he said. “There is a feeling that we should just give up, because now we’re never getting out,” he said. “There were a lot of heavy sighs.”

Minnesota has long stood out among the states for both the number of sexual predators it commits and for the duration of their confinement without review. During a federal trial in 2015, MSOP administrators admitted they may be detaining untold numbers of offenders who no longer meet the statutory criteria for confinement.

In a history spanning more than 20 years, the MSOP has granted conditional discharge to only 14 offenders. Only one person, a 26-year-old confined for sexual acts he committed as a juvenile, has been fully discharged from MSOP, and that did not occur until August of this year.

In June 2015, U.S. Judge Donovan Frank in St. Paul declared the MSOP unconstitutional, citing the program’s low rate of release and lack of regular risk evaluations of offenders. While Frank stopped short of closing the program, he ordered state officials to make reforms designed to put less-dangerous offenders on a clearer path toward release. These included independent risk assessments of the roughly 720 offenders confined at secure treatment centers in Moose Lake and St. Peter, and the development of more options for housing offenders in the community. The Eighth Circuit Court had stayed these reforms while Frank’s decision was on appeal.

The threat of more radical sanctions, including the possible shutdown of the program and release of hundreds of offenders, acted as a powerful incentive for state officials to make the program less punitive. A record number of detainees at the MSOP have been moved closer toward release, and a total of 89 are now in dormlike settings on the MSOP’s St. Peter campus, the final step before release.

However, with the ruling Tuesday, the MSOP will no longer be under constant pressure to demonstrate that its program is not just a punitive system for segregating offenders, say legal experts.

“This is a train wreck for civil rights,” said Warren Maas, an attorney who represents sex offenders. “My concern is that staff at MSOP will ... stop working as hard and just say, ‘We’re going to let these guys sit because it’s the easiest thing to do.’ ”

But in an interview Tuesday, Human Services Commissioner Emily Piper made it clear that her agency would continue with improvements at the MSOP, including pressing forward with millions of dollars in new infrastructure. In his bonding bill last year, Gov. Mark Dayton sought $12.4 million to build two facilities to house discharged sex offenders in the community, as well as $14.5 million to expand housing at a program at St. Peter designed to reintegrate offenders into the community. Dayton also sought funding to conduct more regular assessments of MSOP clients.

For his part, Dayton said Tuesday that the ruling “means we can continue to make the reforms that we have started at our own pace … rather than having it be done under a federal directive.”

While the governor’s funding proposals failed last spring, Piper said she anticipates renewing them. “The need still exists. Nothing in this ruling will change the way we operate this program.”

Even so, the ruling may reduce pressure on Minnesota and other states to pursue reforms of civil commitment programs that hold offenders beyond their prison terms, said Eric Janus, a law professor at Mitchell Hamline School of Law and author of a book on sexual predator laws.

“This decision will send a signal to states that they don’t have to worry too much about the federal courts looking over their shoulders,” Janus said. “Essentially, the Eighth Circuit has said: We are washing our hands of any kind of meaningful oversight of this kind of post-prison confinement.”

Staff writer Ricardo Lopez contributed to this report.

Twitter: @chrisserres