"He felt that he was all people in the world, and had to be born again to become the new Jesus," the prosecutor Carl Graff Hartmann said in his opening statement on Monday. "He wanted to take Marius and Andreas with him. Then he planned to take his own life."
When police arrived at the scene the 23-year-old had scrawled the word "God" in blood over the doorway.
The 23-year-old is pleading not guilty to manslaughter on the grounds that he was psychotic at the time of the attacks, which took place on Halloween in 2011.
One of the two friends, Andreas Nilstad (22), died after being stabbed several times in the head, chest and back. The other, Marius Løken (24), miraculously survived, despite being stabbed 15 times in the upper body.
If the court accepts that the accused was psychotic, it must then determine whether the psychosis was drug-induced, in which case the man could still be found guilty.
He had been smoking marijuana and drinking alcohol in the run up to his attacks.