MINNEAPOLIS (AP/WCCO) — A federal judge declared Minnesota’s sex offender treatment program unconstitutional Wednesday and gave the state’s political leaders one last chance to propose solutions that would protect the “fundamental rights” of 740 people locked up indefinitely before he imposes remedies himself.

U.S. District Judge Donovan Frank sided with patients who were civilly committed to the Minnesota Sex Offender Program after completing their prison sentences. He agreed that given the program’s 20-year history, no one in it has “any realistic hope of ever getting out,” even if they do well in treatment and are at low risk of committing new crimes. Instead, he said, it’s undisputed that some residents no longer meet the criteria for commitment or could be released into less-restrictive settings.

READ MORE: Eli Hart’s Former Foster Mom Remembers 'An Amazing Kid'

“The stark reality is that there is something very wrong with the state’s method of dealing with sex offenders in a program that has never fully discharged anyone,” Frank wrote.

Yet Frank ordered no immediate changes or releases, instead urging top political leaders to bring proposed remedies to proceedings that will begin on August 10. Otherwise he made it clear he would impose his own. He suggested more than a dozen, including more reliance on alternate, less-restrictive facilities. He said he may appoint a special master to ensure compliance. And he warned that a failure to come up with an acceptable plan could lead him to order the closing of the St. Peter and Moose Lake facilities or the extensive release of patients.

Minnesota has struggled for years with the rising costs of its policy on sex offenders, spending millions to expand and update the two the prison-like facilities. It costs more than $124,000 a year to house just one resident, triple the cost of prison.

WEB EXTRA: Read The Full Ruling (.PDF)

But lawmakers, many fearful of appearing soft on crime, have resisted any substantive changes. Just this year, legislators declined a proposal to buy land for and design two facilities aimed at housing sex offenders on course for eventual release. They also declined to provide requested funds that would have allowed the program to carry out some of the judge’s recommendations, such as periodic risk assessments for each resident.

“This is a very powerful statement by Judge Frank. I think it’s an indictment of the Minnesota political system,” Dan Gustafson, the lead attorney for the plaintiffs in the class action lawsuit, said at a news conference. “These issues are not new to the state of Minnesota but the political system has failed to act on it, and I think that frustration comes out in the judge’s opinion pretty clearly.”

Both Gov. Mark Dayton and Human Services Commissioner Lucinda Jesson said they still believe the program is constitutional and plan to defend the law. However, they both stopped short of saying they would appeal.

“We intend to defend the constitutionality of our sex offender program and we’re looking at the best way to do that,” Jesson said in an interview.

While the state is criticizing the ruling, it is being celebrated by the sex offenders themselves.

READ MORE: Next Weather: Slightly Warmer Start To The Work Week

When Craig Bolte was 14, he sexually assaulted an 11-year-old girl. That was almost 28 years ago, and Bolte has been at the Moose Lake facility for nine years.

“I am in a situation where I thought we were never going to see freedom,” he said. “Locked up since the age of 15, and all of a sudden all my hope came back.”

Bolte said there were scenes of cerebration throughout the Moose Lake facility.

“There are people who are literally crying tears of joy,” he said.

Frank said the 67 offenders who, like Bolte, committed offenses as juveniles should get speedy priority for evaluations and possible release.

Late Wednesday afternoon the Minnesota Attorney General’s office filed a letter with the court asking for the right to make an immediate appeal of the day’s ruling.

Former Minnesota Supreme Court Chief Justice Eric Magnuson, an appellate law expert who also led a task force that recommended reforms to the program, said he doesn’t believe Frank’s order is appealable yet because the case isn’t over and he hasn’t entered a final order. While the state already asked the judge to allow an appeal now, Magnuson said the state likely will have to wait until Frank actually orders it do something.

Gustafson said fixing the program will require a combination of legislation and executive action. He said the Department of Human Services can make some changes by itself, but some will require money that likely will have to come from the Legislature. And he said there are some things in the law that only the Legislature can change.

Sen. Kathy Sheran, who leads a committee that oversees the program, said that even if state leaders opt to challenge the ruling they should immediately begin work on a fallback.

“I don’t think the Legislature should wait to be told what to do when they already know what to do just to avoid a politically tough vote,” said Sheran, DFL-Mankato.

Frank wrote that some sex offenders are “truly dangerous and should not be released,” but others should have been freed some time ago. The court must balance citizens’ constitutional rights without compromising public safety and the interests of justice, he said. “The balance is a difficult and important one, but it can and will be done.”

MORE NEWS: Sen. Klobuchar Pushing To Help Modernize Minnesota National Guard's Fleet

(TM and © Copyright 2015 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2015 CBS Broadcasting Inc. Used under license. All Rights Reserved.This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)