HOULTON, Maine — The man accused in the brutal slayings of three people in Amity in 2010 was suffering from a delusional disorder when he committed the crimes, a defense psychologist testified Wednesday.

But prosecutors said that Thayne Ormsby was aware enough during the murders to have cleaned up the crime scene and then fled. They also presented a psychologist who acknowledged that Ormsby was not mentally healthy but that he did not have a delusional disorder and was not psychotic when he committed the crimes.

During the second day of testimony Wednesday in Aroostook County Superior Court, Dr. Kathryn Thomas, a psychologist who interviewed the 21-year-old accused killer and also completed psychological tests on him, said that evidence gleaned from those tests revealed Ormsby was suffering from a delusional disorder, a type of psychosis in which the sufferer feels that something is happening to them or around them when it really isn’t. Thomas said that she was “very certain” of the diagnosis.

Ormsby was convicted on April 13 in the stabbing deaths of Jeffrey Ryan, 55, Ryan’s son Jesse, 10, and Ryan family friend Jason Dehahn, 30, all of Amity, on June 22, 2010. They were found dead about 27 hours after the killings at the elder Ryan’s home on U.S. Route 1, according to police. All three died of multiple stab wounds. Ormsby also was found guilty of arson for burning Jeff Ryan’s truck after he stole it from the murder scene.

Before the start of the murder trial, Ormsby pleaded not guilty and not guilty by reason of insanity to the charges. Because of his insanity plea, Ormsby is being tried in two phases. The jury found Ormsby guilty during the first phase of the trial last week. This week, the jury is hearing evidence as to his state of mind at the time of the crimes. They will be asked to determine whether Ormsby was criminally responsible for his actions. The jury’s decision must be based on a preponderance of the evidence rather than on reasonable doubt as it was during the criminal phase of the trial. The burden also is on the defense to prove that he was insane.

Assistant Attorney General Andrew Benson cross-examined Thomas at length Wednesday about her diagnosis and challenged it based on several factors. He argued that Ormsby was aware of where he was and what he was doing when he committed the murders. He also said Ormsby knew what he was doing was wrong and that he could be caught for it. He went to the sink to wash his hands after the murders, took items from the crime scene that had his fingerprints on them and threw the knife used in the slayings into a bog.

Ormsby thought that Jeff Ryan was a “bad man” and that he was a drug dealer. No evidence supports that allegation.

Thomas said Ormsby believed that he was doing his job when he killed Jeff Ryan and that he killed the other two victims when it became obvious they would implicate him. She said Ormsby also thought he was making the world a better place by committing the crimes. She said that in his mind, the slayings would elevate his status as an assassin.

She also said Ormsby was “out of touch with reality,” “self centered” and had “delusions of grandeur.”

Thomas said it was Robert Strout who told Ormsby that Ryan was a drug dealer. Ormsby stayed with Strout and his wife in their Orient home in the weeks leading up to the murders, and Ryan was the father of one of Strout’s grandchildren. Strout reportedly also talked to Ormsby about his time in Vietnam and discussed killing people.

Benson countered that it was difficult to tell whether a person was suffering from a delusion or just believed something that was untrue.

During the afternoon session, Dr. Debra Baeder, chief forensic psychologist at the State Forensic Service, took the stand to refute the diagnosis of delusional disorder.

Baeder also conducted a psychological evaluation on Ormsby. She acknowledged that he was not mentally healthy because of his chaotic and traumatic upbringing. Ormsby was taken away from his mother and sent to live with his uncle when he was 12 years old because of abuse and neglect at the hands of his estranged mother, Maria Ormsby, who has been in court all week.

“He was immature and had a very fragile ego that needed to be fed by others,” Baeder told Benson. “That is owing to his childhood.”

Baeder said she believes Ormsby was not psychotic because of the “series of rational actions” he took after the murders, such as cleaning up the crime scene, burning his clothes and fleeing the state. She said that his allegations about Jeff Ryan were mistaken beliefs, not delusions.

She agreed that Ormsby felt his actions “would hone his skills as an assassin.”

Testimony will continue Thursday.