TORONTO — A man who allegedly said Allah instructed him to kill was charged Tuesday with stabbing and wounding two uniformed soldiers at a north Toronto military recruitment centre a day earlier.

While investigators were probing possible terror links, the city’s police chief said there didn’t appear to be any connection to terrorist groups, although it seemed the man had deliberately targeted military personnel.

“To date, there is nothing to indicate the accused is working with anyone or in concert with any organization,” Chief Mark Saunders said. “It will take some time to have a complete picture.”

The incident occurred mid-afternoon Monday, when a man walked into the government building that houses a Canadian Armed Forces recruitment centre on the ground floor.

He walked into an office with a “large knife” in hand and began striking a uniformed master corporal, who fell to the ground, Saunders said. The soldier was able to get to his feet, at which point the suspect slashed his right arm.

As military personnel moved civilians to safety, investigators said the man tried and failed to slash a female soldier before other soldiers were able to subdue him and hold him for police. Another military member was injured as they apprehended the suspect.

“While at the scene, the accused stated that ‘Allah told me to do this Allah told me to come here and kill people,”‘ Saunders said.

Following the arrest, the accused became “non-responsive,” Saunders said, meaning he refused to answer any police questions.

Two soldiers needed treatment for minor injuries.

Police named the suspect as Montreal-born Ayanle Hassan Ali, 27, who moved to Toronto in 2011. At one point, they also spelled his first name as Ayanie, but offered no explanation for the mistake.

Ali was charged with a total of nine counts, according to court documents: three attempted murder, two aggravated assault, three assault with a weapon and possession of a dangerous weapon.

The accused hung his head and looked down at the floor for most of a brief court appearance Tuesday, saying his name quietly when asked to do so. He was remanded until Friday.

“He just seems very scared right now and of course very, very unhappy to be in the position he finds himself in today,” his lawyer, David Burke, said outside court. “It’s a very, very difficult situation.”

Burke said he might seek bail for Ali on Friday if he can find strong sureties for the man, but refused to discuss his client’s current living arrangements.

The incident at the recruiting centre evoked memories of two separate attacks in 2014 that left two soldiers dead, one in Ottawa and another in Montreal. Investigators said both accused in those cases had become radicalized.

In a tweet Tuesday, Prime Minister Justin Trudeau said Canada’s military would “not be intimidated by terror and hate.” He also wished the injured soldiers a full recovery.

Police were working with federal security and anti-terrorism forces on the investigation into the Toronto incident. At the same time, Saunders warned the public against any anti-Islam sentiment in the aftermath of the attack, saying Islamic extremists are relatively tiny in number.

“One of the things I want to be very careful of when it comes to the national security piece that we don’t go do that Islamophobia nonsense,” Saunders said. “I don’t want this categorizing of a large group of people that would be very unfair and very inaccurate.”

Saunders said the Canadian citizen had no previous criminal record, and he appealed for anyone who might have helpful information to contact them. Police were obtaining search warrants for the man’s west-end home. They also said he had family, but did not elaborate.

A spokesman at the recruiting centre said it was the first such attack at the facility.

“They are very rare, very exceptional,” Capt. Rony Khalil said, adding that staff worked quickly to respond to the knife-wielding man.

“We were able to immobilize the assailant and then the police was engaged, EMS was engaged and military police was engaged as well,” he said. “We always come together.”

The two injured Canadian Armed Forces members had given statements to police.

“They are OK,” he said. “The injuries were very minor.”

Few signs of the incident lingered at the building by Tuesday: A police car was stationed outside and a few private security guards were spotted around the building, which also houses Passport Canada and Service Canada offices.

“Everything is back to normal today,” Khalil said.

“We do take care of always having security measures in place to protect not only our members but, more importantly, people that come into our centre, and that hasn’t changed.”