This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

A convicted California rapist who spent 13 years in prison and nearly 14 years in a state mental hospital while awaiting a trial that never came has been ordered released.

A state appeals court in San Francisco ruled Wednesday that Terrance Butler was denied a timely trial, the San Francisco Chronicle reported.

Butler will remain confined while prosecutors decide whether to appeal.

He was convicted of raping two women and was nearing release from prison when Alameda County prosecutors asked a civil court to declare him a sexually violent predator.

That would have allowed Butler to be kept in a mental institution indefinitely, but the trial never came.

Butler has been hospitalized since 2007, awaiting the long-postponed trial.