A man who went on a bloody stabbing rampage at a Toronto office while he was being fired was found not criminally responsible for his actions by an Ontario court Tuesday, in a decision a judge called "an extremely close call."

Chuang Li was charged with three counts of attempted murder, four counts of aggravated assault and four counts of assault with a weapon in an incident that captured the city's attention last April.

Four people were taken to hospital, two of them with life-threatening injuries, after Li started stabbing people while he was in the process of being fired from human resources company Ceridian Dayforce Corporation.

His trial heard that Li suffered from a mental illness at the time and had been carrying knives with him even before the incident because he thought he was being watched by "an organization" that was out to get him.

"I am satisfied on a balance of probabilities that Mr. Li was not criminally responsible by reason of mental disorder," said Justice Fergus O'Donnell. "But by a very narrow margin."

Li showed little emotion as his verdict was delivered, nodding only slightly when the judge addressed him.

He has been in custody since the incident and will now go before the Ontario Review Board, which will determine which hospital he will receive treatment in, and at what level of security he will be held.

Li's lawyer said his client suffered from paranoid delusions at the time of the incident.

"Mr. Li is still very confused about the process because he does suffer from a major mental illness," John Rosen said outside court, noting his own satisfaction with the outcome. "I always thought it was the right result."

Li had difficulties maintaining stable employment after immigrating to Canada in 2001 and was employed by 12 different companies between 2006 and 2012, before being hired by Ceridian.

Court heard that Li's wife noticed her husband beginning to act strangely in 2009, saying "very funny things" about the people he worked with and sometime in 2011, began talking about an "organization" that was trying to "set him up."

Li told a forensic psychiatrist he began carrying a saw with him in November 2012 because he felt unsafe in his neighbourhood, his trial heard.

In February 2013, Li began carrying a large knife in his shoulder bag, saying he didn't feel safe at the office. In June that year, he bought a pocket knife, which he also took to work, and in March 2014 he bought another knife which he kept in his car, court heard.

Ceridian decided to end Li's employment on April 9, 2014, and he was called into the office of human resources manager Rajsri De, where vice-president of development, James Konandreas, began reviewing Li's performance issues.

Li began to hurl expletives and then pulled out his pocket knife, court heard.

His trial heard he began to stab Konandreas and De. When De was cornered in a hallway, Li slashed her face and hands and stabbed her in the stomach, and then went after Konandreas, court heard.

Another manager, Scott Berenthal, who tried to intervene, received a stab wound on his head.

Bryan Humphries, whose office was beside De's, saw the commotion and kicked Li, who charged at him, stabbing him in the arm.

Li eventually ended up standing over a collapsed Konandreas, who he continued to stab, before an employee who spoke Mandarin convinced Li to surrender his knife, court heard.

His trial heard that the 49-year-old told the officers arresting him that his victims deserved the attack.