Months before he allegedly killed a family friend in Harford County, eating his heart and parts of his brain, Alexander Kinyua was suffering from paranoid schizophrenia and believed reptilian aliens were coming to destroy Earth, a judge said Wednesday.

The revelations about the slow but steady deterioration of Kinyua's mind came as Baltimore Circuit Judge Gale E. Rasin accepted his plea of guilty but not criminally responsible on separate allegations that he attacked a fellow Morgan State University student with a baseball bat wrapped in barbed wire.

Kinyua had been detained in a state treatment center for months. At the hearing, he entered his own plea and apologized for the May beating that left Joshua Ceasar legally blind.

"My deepest apology and sympathies will not be able to cover up what happened," said Kinyua, 22.

By accepting Kinyua's guilty plea to attempted first-degree murder along with the clinical assessment that he didn't comprehend what he was doing when he attacked Ceasar, Rasin committed him indefinitely to a psychiatric hospital. A team of doctors and an administrative law judge would have to agree to his release.

"The evidence is overwhelming that Mr. Kinyua was suffering from a mental illness at the time of the offense," Rasin said.

Harford County prosecutors say they will now push forward with a charge of first-degree murder that had been delayed by competency questions. Kinyua is accused of dismembering Kujoe Bonsafo Agyei-Kodie, a 37-year-old Ghanaian national staying in Kinyua's family home, just days after he was released on bail in Ceasar's attack.

Explaining her decision to Ceasar, Rasin offered the most detail made public to date about Kinyua's mental illness. She also said Kinyua had sought student counseling at Morgan State after exhibiting episodes of bizarre and violent behavior, meeting with a counselor for an hour but leaving without any follow-up or recommendations.

Rasin said she couldn't predict whether Kinyua would ever be released from medical treatment, but the possibility disturbed Ceasar.

"I don't agree with the court system that he has a chance to be let go," Ceasar, 22, said through tears and thick, black-rimmed glasses. "He shouldn't see the light of day."

Still, he said, he forgave Kinyua.

When it was his turn to speak, Kinyua, who takes two psychotropic drugs, rose to his shackled feet.

"I don't forgive myself," he said.

Until 2011, Kinyua, an electrical engineering student and son of a Morgan State physics professor, was an ordinary student.

Reading from a 23-page psychiatric report that included educational records, mental evaluations and witness statements, Rasin said Kinyua began hallucinating and eventually created a delusional universe.

He believed he was a prophet with secret powers. He wrote a manuscript about the history of mankind. He talked about a "Reptilian agenda" from outer space. His stories featured African slaves and the Bermuda Triangle, Rasin said.

Kinyua stopped going to school and church, developed his own spiritual beliefs and started spending time as a spiritual medium. He said he was a shaman. He burned incense and brought home animal parts — once a dead fox — that he told his father and others he used in religious exercises.

Deeply affected by the 1998 Kenyan embassy bombing, 9/11 and Hurricane Katrina, he worried whether his family had an escape plan. Kinyua began stashing extra food at home. His mother eventually got hold of his manuscript and found it to be "gibberish," Rasin said. He became quiet and secretive.

In December 2011, released from ROTC, he believed people had sabotaged his computer records and had conspired to get him drunk, causing him to miss a football game. He punched holes in an office wall, prompting an ROTC official to call him a "Virginia Tech waiting to happen."

In January, his mother urged him to seek counseling for anger management problems, Rasin said. Kinyua saw someone in student counseling who the judge said didn't follow up.