MUNCIE, Ind. -- A central Indiana man who spent nearly 25 years in prison left a courthouse a free man Wednesday after a judge set aside his 1992 rape conviction because DNA found on the victim was not his.

Delaware Circuit Judge Kimberly Dowling freed William E. Barnhouse, acting on a joint motion filed by prosecutors and attorneys with the Innocence Project, after recent DNA tests showed another man’s semen was on the pants and inside a 1992 Muncie sexual assault victim, The Star Press reported.

“He has spent a quarter of a century incarcerated for a crime he did not commit,” Innocence Project attorney Seema Saifee told the judge. “William has suffered from mental illness his entire life. ... He never gave up hope that the truth would come out.”

Get Breaking News Delivered to Your Inbox

Barnhouse, now 60, was accused of attacking a woman in April 1992 behind a vacant Muncie building. The victim identified him as her attacker after he was arrested nearby. He was found guilty, but mentally ill, of rape and criminal deviate conduct, and sentenced to 80 years.

Dowling also granted a motion that Barnhouse be released for treatment and evaluation at an Indianapolis mental health facility.

“You’ve got to do everything they say,” the judge told Barnhouse.

Barnhouse left the courthouse with his attorneys and relatives, but his case may not be over. Delaware County prosecutors will decide in coming weeks on whether to bring Barnhouse to trial a second time, Chief Deputy Prosecutor Eric Hoffman told the judge.

For now, Saifee said her client has simple plans to enjoy his current freedom.

“He’s just hoping to get a good meal and enjoy the sun,” she said.

Court records show the Innocence Project, a nonprofit that has exonerated more than 300 convicted felons through DNA results, first inquired about evidence in Barnhouse’s case in 2009.

Negotiations with prosecutors led to a January 2016 agreement allowing the DNA testing.