TORONTO (AP) — A man who attacked Canadian soldiers at a military recruitment center in Toronto has been acquitted of terror-related charges and found not criminally responsible for lesser charges due to mental illness.

Judge Ian MacDonnell said Monday Ayanle Hassan Ali's actions in May 2016 don't fit the intended scope of Canadian terrorism laws. Three soldiers were hurt when he slashed at them with a kitchen knife. None of the injuries was serious.

Both the prosecution and defense agreed Ali had a serious mental illness. His lawyers had argued he should be found not guilty on the terror charges because he committed his actions alone and hadn't been in contact with terror groups.

They also argued he shouldn't be convicted of the lesser included charges of attempted murder, assault and weapons offences.