A judge has ruled that a man accused of stabbing his former co-workers in a north Toronto office building last year is not criminally responsible.

The attack happened on April 9, 2014, just after 9:30 a.m. on the fifth floor of an office complex at 4110 Yonge St., near York Mills Avenue.

An Ontario judge said his decision in Chuang Li's case was "an extremely close call," but he ultimately found the 49-year-old not criminally responsible due to a mental disorder.

Li was charged with three counts of attempted murder, four counts of aggravated assault and four counts of assault with a weapon.

Three men and one woman — employees of a human resources company — were sent to hospital with injuries following the attack.

Li started stabbing people while he was in the process of being fired from the human resources company Ceridian Dayforce Corporation.

Li's trial heard he had told officers arresting him that his victims deserved the attack.

John Rosen, Li's lawyer, said his client suffered from paranoid delusions at the time of the incident and "was unable to differentiate right from wrong."

Rosen said Li's case will go before the Ontario Review Board (ORB) within the next 45 days, and it "will decide what level of security of hospital he will go to for treatment."