DES MOINES, Iowa — The Iowa Supreme Court on Friday dismissed the state’s efforts to confine indefinitely two men convicted for sex abuse crimes under a state law allowing sexually-violent predators to be committed.

The court concluded that Nicholas Wygle, of Aplington could not be further imprisoned because he had completed his two-year prison sentence for assault with intent to commit sexual abuse and was serving a special 10-year sentence in an Ames residential facility when the state began its civil commitment proceedings.

The court concluded state law only allows officials to commit sexual predators if they’re “presently confined” or if they commit another sex-related crime. Wygle had not committed another crime and the court concluded being in a residential facility is not the same as being presently confined.

As a result, the court ordered the case dismiss and Wygle, 29, will not be held in the civil commitment program.

In a second case, Ronald Tripp, 66, of Hazleton will be released from civil commitment after the court ruled his case should have been dismissed. The justices concluded the state lacked evidence to show Tripp committed another sex-related crime that justified civil commitment.

State civil commitment programs have been challenged in court cases that have reached the U.S. Supreme Court.

There is a case currently scheduled for trial Oct. 1 in federal court in Cedar Rapids in which nine men claim the Iowa civil commitment program is unconstitutional because it fails to offer adequate counseling and other services that would rehabilitate them enough for release.

Court challenges to Iowa’s law enacted in 1998 highlight the difficult balance states must strike between keeping dangerous sexual predators off the streets and not violating their constitutional rights by imprisoning them longer than their court-mandated sentences.

“Preventive detention is very limited in American law because it is seen as antithetical to fundamental liberty interests and the presumption of innocence,” wrote Justice Brent Appel in the Iowa Supreme Court’s majority opinion Friday in Wygle’s case.

He said sexually violent predator statutes “threaten to deprive individuals of what from time immemorial has been the weightiest of interests — the interest in individual liberty.” He said the vague and flexible standards of the statutes allows, if not encourages, “a better-safe-than-sorry approach” of locking up sex crime violators indefinitely.

Both cases were decided by a split 4-3 decision.

Justice Edward Mansfield wrote dissenting opinions in both. In the Wygle case he said a person in a residential facility should be considered to be in custody and the court should have upheld his civil commitment proceeding.

In Tripp’s case he said there was substantial evidence that Tripp committed another sex-related crime in 2013 by groping a woman and the court should have sent his case back to district court for a trial to prove the groping met the definition of a sex-related crime that qualified him for civil commitment as a sexually violent predator.