A federal judge said Wednesday he will rule on the fate of Minnesota’s sex-offender treatment program within 30 days, hoping to protect the civil liberties of its patients but also communities where offenders might be released.

U.S. District Judge Donovan Frank has already found the Minnesota Sex Offender Program (MSOP) unconstitutional; during a morning court hearing Wednesday he heard arguments on its future from attorneys representing a group of confined sex offenders and from the state agency that runs the program’s two locked treatment facilities.

“What I’m trying to avoid is what’s happening in California and other states,” he said during the hearing in St. Paul, “where they tried to fix some things and nothing happened, so they started releasing people without a transitional plan in place.”

A group of sex offenders confined for years at treatment centers in St. Peter and Moose Lake sued four years ago, claiming that the state wasn’t routinely assessing their progress toward discharge or providing enough transitional care facilities to which they could be moved.

Frank ruled in June that the program is “clearly broken” and unconstitutional, but state officials since then have rebuffed his requests for reforms.

If state officials won’t comply with the court order, the judge should feel free to recommend the reforms he wants and threaten fines if the state doesn’t comply, said Dan Gustafson, who represents the confined sex offenders. “Because they failed to give you any proposals, I think you are free to choose among the remedies that you see fit,” Gustafson told Frank.

While the Dayton administration has agreed on the need for reform, officials have insisted that the MSOP is constitutional and said they would ultimately appeal Franks’ ruling from June and whatever remedies he orders in October.

In a recent court filing, Human Services Commissioner Lucinda Jesson called many of the reforms suggested by Gustafson “impractical and costly.”

Deputy Minnesota Attorney General Nate Brennaman, representing the state, said any sweeping reforms should come from the Legislature, not from a judge. He argued that the case isn’t legally about the MSOP itself, but rather whether specific state officials named as defendants wronged the sex offenders who filed the suit. With that in mind, he said Gustafson hadn’t proved that any of his clients were wronged or specifically deserving of earlier discharges.

“It was the plaintiffs’ job at trial to show people were being held unconstitutionally when they should be free,” Brennaman said.

Legal scholars and state leaders generally agree that the state’s manner of treating sex offenders needs improvement, but also that politicians are wary of defending the rights of an unpopular constituency.

The MSOP’s population has grown rapidly in the past 15 years, to more than 700 offenders, and Minnesota now confines more sex offenders per capita than any other state. Each offender in confinement costs the state $120,000 per year.

Gustafson said detaining and treating sex offenders was a burden the state chose to take on — about 30 states have no comparable civil commitment program — and that Minnesota consequently needs to live up to its obligation of treating patients while preserving their liberty.

“They can’t say it costs too much to run it in a constitutional manner,” Gustafson said. “That can’t be a defense because they chose to take these people into custody.”

Hennepin County Attorney Mike Freeman offered impromptu testimony at the hearing, representing himself and attorneys from six other counties. While saying he believes the MSOP is constitutional, he said it is too big and confines some sex offenders longer than necessary.

“Simply not to allow folks to [progress toward discharge] — as has been the history of the program — is not right,” Freeman said.

After the hearing, Jesson said she has been a “fierce advocate” for reforms and that the state since 2012 has made the first meaningful steps toward moving patients closer to discharges from the locked facilities.

However, she said she doesn’t have a “magic wand” to reform the system without additional state funding, or without sacrificing services to people with disabilities, the elderly or others served by her agency.