The man who shot and killed Cpl. Nathan Cirillo at the National War Memorial and was gunned down himself on Parliament Hill Wednesday morning told a B.C. judge almost three years ago that he was homeless and wanted to go to jail to help break his drug addiction.​

Salvation Army Beacon shelter in Vancouver's Downtown Eastside

A spokeswoman with the Salvation Army confirmed that Ottawa gunman Michael Zehaf-Bibeau stayed at the Beacon shelter, but would not say when. (CBC)

Montreal-born Michael Zehaf-Bibeau, 32, lived in B.C. in recent years, walking the streets of Vancouver, Burnaby, and Surrey, and may have been staying at a Salvation Army shelter in downtown Vancouver as recently as two weeks ago.

Zehaf-Bibeau was also charged with robbery and uttering threats for an incident in Vancouver on Dec. 16, 2011, which court records indicate may have been an attempt to get help. CBC News obtained the psychiatric assessment and audio recordings of Zehaf-Bibeau's court appearances in Vancouver on Dec. 2011 and Feb. 2012.

'He believes his must spend time in jail as a sacrifice to pay for his mistakes in the past and he hopes to be a better man when he is eventually released.' - Dec. 2011 psychiatric assessment

The psychiatrist, who met with Zehaf-Bibeau at the Surrey Pre-Trial Centre, found that he was fit to stand trial, and explained some of Zehaf-Bibeau's motivation for wanting to be imprisoned.

"The accused is aware of his charge and possible consequences of conviction. He wants to be in jail as he believes this is the only way he can overcome his addiction to crack cocaine. He has been a devoted Moslem for seven years and he believes he must spend time in jail as a sacrifice to pay for his mistakes in the past and he hopes to be a better man when he is eventually released," the psychiatrist wrote on Dec. 18, 2011.

At Zehaf-Bibeau's bail hearing, he told the judge himself that he wanted to serve time.

'I'm a crack addict and at the same time I'm a religious person... I want to sacrifice freedom and good things... so when I come out, I'll appreciate the things of life more and be clean.' - Michael Zehaf-Bibeau, Dec. 2011

"Yeah, I confessed to an armed robbery 10 years ago. I wanted to come to jail so I could clean up," he said.

"I went to see the RCMP, I told them, 'just put me in so I could do my time for what I confessed.' They couldn't. So, I warned them, 'if you can't keep me in, I'm going to do something right now just to be put in.' So I went to do another robbery just so I could come to jail," Zehaf-Bibeau said.

"I'm a crack addict and at the same time I'm a religious person, so I want to sacrifice freedom and good things for a year maybe, so when I come out, I'll appreciate the things of life more and be clean," Zehaf-Bibeau said.

The prosecutor told the judge Zehaf-Bibeau had been sentenced to two years for the robbery in Quebec, and that he shouldn't be sent to jail just because he wants to go. The prosecutor asked the judge to release Zehaf-Bibeau.

'If you release me what's going to happen again? Probably the same loop and I'm going to be right back here again.' - Michael Zehaf-Bibeau, Dec. 2011

"I don't want to be released," Zehaf-Bibeau said. "The reason I am here is because I wanted to come in. The police said they couldn't keep me, so I went to do a crime to come to jail. So if you release me what's going to happen again? Probably the same loop and I'm going to be right back here again."

The judge agreed to detain him over Christmas.

"Perfect," Zehaf-Bibeau said.

Arrest request before McDonald's incident

Almost two months later, in Feb. 2012, Zehaf-Bibeau was back in court on the B.C. robbery charge. His lawyer said he wasn't guilty, but would plead guilty to one count of uttering threats. The circumstances of the case were a little odd, the lawyer told the judge.

The story that came out in court was that Zehaf-Bibeau had walked into the Burnaby RCMP detachment on Dec. 15, 2011, at around 9 p.m. and asked to speak with police about an armed robbery he committed 10 years earlier, for which he wasn't punished, but now wanted to be. 

An officer tried to help him, but couldn't find any record and refused to arrest him. Zehaf-Bibeau was detained under the Mental Health Act, but was released when it was determined he was neither ill nor intoxicated. He told police he was homeless and wanted to go to jail.

'I am unable to find any features or signs of a mental illness and although he seems to be making an unusual choice this is insufficient basis for a diagnosis of mental disorder.' - Dec. 2011 psychiatric assessment

A few hours later, at 1:45 a.m. on Dec. 16, Zehaf-Bibeau went into a McDonald's restaurant in Vancouver, showed a sharpened stick to the clerk and asked for the money in the till. The McDonald's employee initially thought it was joke, as Zehaf-Bibeau was grinning.

Zehaf-Bibeau then reportedly said, "Yes, hand over the money, homeboy."

Police came and arrested him, and he appeared to be happy. Zehaf-Bibeau's lawyer told the judge that Zehaf-Bibeau felt he had an undiagnosed mood disorder, but the court psychiatrist disagreed.

"I am unable to find any features or signs of a mental illness and although he seems to be making an unusual choice this is insufficient basis for a diagnosis of mental disorder," the psychiatic assessment stated.

Zehaf-Bibeau had spent 66 days in custody, and the judge sentenced him to one day more.

Zehaf-Bibeau said he has no income to pay a $100 victim impact surcharge, and the judge gave him until end of August 2012 to pay the fine.

"Good luck to you sir," the judge said.

Masjid al-Salaam and Education Centre, mosque in Burnaby, B.C.

Members of the Masjid al-Salaam and Education Centre, a mosque in Burnaby, B.C., confirmed that Michael Zehaf-Bibeau did attend the mosque in 2011, and possibly as late as 2013. (CBC)

'Kind of rough and maybe a little rude'

CBC News has also learned Thursday that the 32-year-old had a connection to a mosque in Burnaby, B.C., and may have visited it as recently as last year.

Aasim Rashid, a spokesman for the B.C. Muslim Association, said a few people at the Masjid al-Salaam and Education Centre dealt with Zehaf-Bibeau before his arrest in 2011.

Aasim Rashid, spokesman for the B.C. Muslim Association

Aasim Rashid, spokesman for the B.C. Muslim Association, said not everyone at the Burnaby mosque had a good opinion of Zehaf-Bibeau, but that if he was becoming radicalized, he didn't let on. (CBC)

"He apparently was not a very well-mannered person," said Rashid. "The people who have interacted with him described him as kind of rough and maybe a little rude."

"At one point, he raised an objection at the Burnaby mosque that he was sort of floating in and out of for a period of three to four months," Rashid said. "He didn’t like the fact that the mosque was so open and welcoming."

Rashid said that, eventually, mosque administrators sat down with Zehaf-Bibeau and explained that the facility was open to other groups in order to work together on common issues.

"[They said] 'If you have a problem with it, it’s best you go somewhere else,'" said Rashid.

After Zehaf-Bibeau was spoken to, he didn't raise similar concerns again.

Told of a falling out with his parents

Farida Bano Ali, chair of the women's chapter of the B.C. Muslim Association, told CBC News she knew Zehaf-Bibeau from the mosque, and that he was pleasant and charming.

She asked about his family one time during a workshop for social workers, and he expressed, not for the first time, that he was estranged from his parents.

"I asked him a lot of issues, and he said, 'oh, my parents. I come from a family, they don't like me, they don't want me, and so I'm hanging around here,'" Ali recalled.

"As the time went, we noticed some behaviour changes," she said.

Then, one day he seemed to disappear. 

Began sleeping in mosque

However, Zehaf-Bibeau did appear at the mosque again, and at one point he started sleeping inside it.

"At some point, when he got in trouble with the law, and he didn’t have a place to go to, he started sleeping at the mosque without any authorization," Rashid said.

'At some point, when he got in trouble with the law, and he didn’t have a place to go to, he started sleeping at the mosque.' - Aasim Rashid, spokesman for the B.C. Muslim Association

"When the mosque administration found out, they asked him to leave immediately and asked him never to do that again. 

"He stole the keys, and when they found out he had keys, they changed all the locks," he said. 

Rashid said he heard through several people that Zehaf-Bibeau was seen at the mosque again in 2013, just hanging around one afternoon.

Masjid al-Salaam and Education Centre, mosque in Burnaby, B.C.

The locks at the Masjid al-Salaam and Education Centre, in Burnaby, B.C., had to be changed after Michael Zehaf-Bibeau allegedly stole a set of keys to the building. (CBC)

Rashid said that if there had been any signs Zehaf-Bibeau was becoming radicalized, community members would have likely noticed.

"They don’t tolerate that kind of extremist mindset," he said. 

"In fact, being around that Burnaby mosque, if anything, would have been therapeutic for him," Rashid said.  "It would have helped him sort of calm down and come into the mainstream, and sort of open up a little bit."

Hasibullah Yusufzai, a British Columbia man charged under a new anti-terrorism law, is believed to have worshipped at the same Burnaby mosque.

Yusufzai allegedly left Canada to join Islamist fighters in Syria. It is not known whether he and Zehaf-Bibeau knew each other.

With files from the CBC's Eric Rankin, Dan Burritt, Chris Brown, Kirk Williams and Jesara Sinclair