The Utah Supreme Court has ordered Bernt Murphy released from the Utah State Hospital where he has been confined since being found incompetent to stand trial for the 1957 rape of a 5-year-old girl.

In the order released Thursday, the high court vacated a 1985 refusal by 3rd District Judge David Dee to release Murphy, 51, from the mental hospital he entered 31 years ago. The justices ordered the lower court to implement its order that a plan for Murphy's gradual release and aftercare be provided.In 1957, Murphy, a former patient at the State Training School in American Fork, was charged with raping the child but was found incompetent to stand trial and committed to the hospital. Authorities said he also confessed to the 1955 slaying of Jocelyn Hickenlooper, but he never was prosecuted.

Three doctors testified at a 1985 hearing that Murphy was mentally retarded but no longer mentally ill, but they declined to recommend his release, saying he lacked the social skills and controls necessary to function outside an institution.

However, the justices said Dee's order continuing Murphy's confinement was "not based on a finding that he was dangerous, but solely upon the lack of adequate community resources to assist him."

Moreover, the justices wrote, "the State's contention that Murphy is mentally ill seriously misapprehends the significant difference between mental retardation and mental illness.

"Virtually all Murphy's manifestations of abnormal behavior result from his mental retardation and thirty-year institutionalization," the justices wrote.

Murphy's attorney, Brooke C. Wells, who had argued that Murphy's ongoing confinement constituted cruel and unusual punishment, praised the ruling and said the justices had "drawn a real distinction" between mental illness and mental retardation.

She said it likely would take up to three months to find a suitable environment for Murphy, who has the mental capacity of a 12-year-old.