A university student has been found not criminally responsible for an attempt to kill a classmate who lived in his dormitory last year.

Thamer Hameed Almestadi was likely suffering from a brief psychotic episode when he attacked a fellow international student, a judge said Thursday. Almestadi told police at the time that he'd believed God commanded him to sacrifice her.

The Saudi Arabian national will be detained in custody at the forensic psychiatric hospital in Chilliwack.

Almestadi was 18 when he attacked University of British Columbia student Mary Hare in October 2016, the court heard during his trial. Accused of slitting Hare's throat and attempting to choke her, he was charged with attempted murder, aggravated assault and assault with a weapon.

While the Saudi Arabian student pleaded not guilty to the charges, the court heard Almestadi say he "just tried to kill somebody" in a three-hour police interview played during his trial.

During the interrogation, he told Sgt. Kevin Jeffrey that he thought in the moment that he thought she was the devil. He said he'd been overwhelmed with school work and hadn't slept the night before.

Almestadi told Jeffrey felt heartbroken during the interview which took place just hours after the crime. He also detailed the attack in the recording, and said he cut Hare's neck in five seconds.

The victim's voice was also heard during the trial. Hare, a U.S. student who was 19 at the time, took the stand almost exactly a year after she was attacked and spoke in detail about what happened that day.

She described Almestadi – who she'd met briefly before her assault – attacking her with a knife. She fought back against her attacker, grabbing the blade of the knife and breaking it off.

A year later she said she still gets nervous when opening the door, and that seeing the accused in court brought back painful memories.

The Crown said two other students ran into the room, found Almestadi with his legs around Hare's neck and pulled him off her.

Following the attack, police found a box of knives in the accused's dorm room, the court heard.

With files from CTV Vancouver's Maria Weisgarber