He seemed lost, “did not fit in,” had drug problems, and went more than five years without seeing his mother. In recent weeks, he had been living at a homeless shelter and had talked about wanting to go to Libya — or Syria — but became agitated when he couldn’t get a passport.

A day after Michael Zehaf-Bibeau launched a deadly attack on Canada’s seat of government, a portrait of the 32-year-old Canadian began to emerge, along with a possible explanation for what triggered the shooting rampage.

Bob Paulson, commissioner of the Royal Canadian Mounted Police, said that Zehaf-Bibeau — a recent Muslim convert whose father was from Libya — may have lashed out in frustration over delays in obtaining a passport.

“I think the passport figured prominently in his motives. I’m not inside his head, but I think it was central to what was driving him,” Paulson said.

In what the prime minister called a terrorist attack, Zehaf-Bibeau shot a soldier to death at Canada’s national war memorial Wednesday, then stormed the Parliament building, where he was gunned down by the sergeant-at-arms.

The attack was the second deadly assault on Canadian soldiers in three days and forced the country to confront the danger of radicalized citizens in its midst.

It also exposed weak spots in security:

— During the attack, Prime Minister Stephen Harper hid in a closet-like space within a Parliament caucus room. The Mounties who are assigned to protect him were on the other side of the doors to the room. From now on, Paulson said, the Mounties will guard the prime minister around the clock, wherever he goes.

— In the wake of the attack, all members of the Canadian military have been ordered to avoid wearing their uniforms in public while doing such things as shopping or eating at restaurants.

— Earlier this week, the Mounties said there are about 90 people in the country who are suspected of planning to join up with extremist fighters abroad or who have returned from such activity. But Paulson said Thursday that Zehaf-Bibeau was not on that list and was not under surveillance, in part because it was not until after the shooting rampage that they learned from his mother that he wanted to go Syria, where a host of militant groups such as Islamic State are fighting.

As for Zehaf-Bibeau’s passport application, it “was not rejected. His passport was not revoked,” Paulson said. “He was waiting to get it and there was an investigation going on to see whether he would get a passport.”

The difficulty in obtaining a passport appeared to weigh heavily on Zehalf-Bibeau, a petty criminal with a long rap sheet, including a string of drug offenses.

Abubakir Abdelkareem, who often visited the Ottawa Mission, a homeless shelter downtown 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 past three days, “his personality changed completely,” Abdelkareem said. “He was not talkative; he was not social” anymore and slept during the day. Abdelkareem concluded the man was back on drugs.

Lloyd Maxwell, another shelter resident, said Zehaf-Bibeau had lived for some time in Vancouver, then Calgary, then came to Ottawa specifically to try to get a passport, believing that would be more easily accomplished in the nation’s capital.

“He didn’t get it, and that made him very agitated,” Maxwell said. Maxwell said he suggested to the man that he might be on a no-fly list, and “he kind of looked at me funny, and he walked away.”

Expressing horror and sadness at what happened, Zehaf-Bibeau’s mother, Susan Bideau, said 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.

“So I have very little insight to offer,” she said.

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

“Can you ever explain something like this?” asked Bibeau, who has homes in Montreal and Ottawa. “We are sorry.”