The gunman who shot and killed a soldier and then stormed Canada's Parliament once complained that Vancouver mosque he attended was too liberal and inclusive, Muslim leaders said.

Assam Rashid, spokesman for the British Columbia Muslim Association, said Michael Zehaf-Bibeau, 32, visited the Masjid Al-Salaam mosque for several months in 2011 before he was told not to come back.

Mr Rashid said the association has been working on a preventive programme that focuses on minimising the effect of terrorist and criminal propaganda in Canada.

Zehaf-Bibeau shot a soldier dead at Canada's national war memorial on Wednesday, and was eventually gunned down inside Parliament by the sergeant-at-arms.

Canada's Prime Minister Stephen Harper has called the shooting a terror attack, and the bloodshed raised fears that Canada is suffering reprisals for joining the US-led air campaign against Islamic State extremists in Iraq and Syria.

The attack in Ottawa cane two days after a man described as an "ISIL-inspired terrorist" ran over two soldiers in a car park in Quebec, killing one and injuring the other before being shot to death by police. The man had been under surveillance by Canadian authorities, who feared he had jihadist ambitions and seized his passport when he tried to travel to Turkey.

Police have said Zehaf-Bibeau was not being watched, and the motivations behind his attack remains obscure. However, a top police official said Zehaf-Bibeau - whose father was from Libya - may have lashed out in frustration over delays in getting his passport.

"I think it was central to what was driving him," said Royal Canadian Mounted Police Commissioner Bob Paulson.

Unlike the Quebec case, Zehaf-Bibeau's passport had not been revoked or his application rejected, but authorities were still investigating whether to grant him one, Mr Paulson said. The wait appeared to weigh heavily on Zehalf-Bibeau.

Abubakir Abdelkareem, who often visited the Ottawa Mission, a homeless shelter where Zehaf-Bibeau stayed in recent weeks, said Zehaf-Bibeau told him he had had a drug problem but had been clean for three months and was trying to steer clear of temptation by going to Libya.

But in the three days before the rampage, "his personality changed completely," Mr Abdelkareem said. He stopped being talkative and sociable and slept during the day, said Mr Abdelkareem, who concluded Zehaf-Bibeau was back on drugs.

Lloyd Maxwell, a shelter resident, said that Zehaf-Bibeau had come to Ottawa specifically to try to get a passport, believing that would be more easily accomplished in Canada's capital.

"He didn't get it, and that made him very agitated," Mr Maxwell said.

In an email to the AP expressing horror and sadness at what happened, Zehaf-Bibeau's mother, Susan Bibeau, said that her son seemed lost and "did not fit in," and that she hadn't seen him for more than five years until having lunch with him last week.

In a brief and tear-filled telephone interview, Ms Bibeau said that she is crying for the victims of the shooting rampage, not her son.

"Can you ever explain something like this?" said Ms Bibeau, who has homes in Montreal and Ottawa. "We are sorry."