VANCOUVER -- Three years ago, a psychiatrist deemed Ottawa gunman Michael Zehaf-Bibeau mentally fit to stand trial on a Vancouver robbery charge despite his “unusual choice” to refuse bail, remain in prison to fight a crack cocaine addiction and “pay for his mistakes in the past.”

New court documents released by a B.C. Provincial Court judge Thursday afternoon paint the picture of a young man so desperate that he attempted robbery to go to jail, which he saw as the “only way to overcome his addiction to crack cocaine.”

Police picked up Zehaf-Bibeau on Dec. 16, 2011 following an incident at a McDonald’s restaurant at Main Street and Terminal Avenue. According to the Crown, he entered the building with a sharpened stick and asked a clerk for money. The clerk asked the smiling would-be robber if he was serious, then called police. The accused went outside and sat down on a backpack to wait for the officers.

During a psychiatric assessment at the Surrey pre-trial centre two days later, Zehaf-Bibeau said he had been a devoted Muslim for seven years and “hopes to be a better man when he is eventually released.”

At a court appearance the next day that was recorded on audio, crown prosecutors said they were prepared to let Zehaf-Bibeau walk, but he did not want to come out of prison.

“I don’t know if you read my file,” Zehaf-Bibeau said to the judge in a brisk but composed fashion. “I confessed to an armed robbery 10 years ago. I wanted to come to jail so I could clean up.”

“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 explained to the judge why he wanted to stay in prison.

“I’m a crack addict, and at the same time, I’m a religious person. I want to sacrifice freedom and good things for a year, maybe and when I come out, I’ll appreciate things in life more and be clean, or maybe get therapy if you guys can — like a detox.”

The judge decided to detain Zehaf-Bibeau on secondary grounds, which is a form of detention made for the protection of the public in the fear an accused may commit an offence if released.

Zehaf-Bibeau got his wish to remain in prison, but not for long.

On Feb. 22, 2012, Zehaf-Bibeau returned to court. His duty counsel, Brian Anderson, entered on behalf of his client a guilty plea to one count of uttering threats, a lesser offence arising from the robbery.

The crown prosecutor said time served would be the appropriate sentence for the guilty plea, noting that Zehaf-Bibeau had already spent 66 days in jail.

During the appearance, the Crown revealed that Zehaf-Bibeau went to the Burnaby RCMP detachment on Dec. 15, 2011 to confess about an armed robbery he said he committed in Quebec 10 years earlier. The constable could not find a record of the robbery and refused to arrest him, according to an audio recording of that appearance.

But he did arrest Zehaf-Bibeau that night under section 28 of the Mental Health Act, in which police can apprehend a person whom is likely to endanger his own or someone else’s safety and is “apparently a person with a mental disorder.”

The constable took Zehaf-Bibeau to Burnaby Hospital, but staff there determined he did not suffer from a mental illness.

Anderson said Zehaf-Bibeau was then driven to a detox centre in Vancouver, but the centre would not take him because he was not intoxicated. The robbery happened a short time later.

When the judge asked how Zehaf-Bibeau supported himself, Anderson said: “He’s from a really good family in Montreal. He works on construction, odd jobs. He was between jobs when he was in Vancouver.”

He came to the west from Quebec for a “fresh start” and “not to be in these courts,” said Anderson.

The judge gave him one more day in prison, six months to pay a $100 fine, and told him, “good luck to you, sir.”

During his time in Vancouver, Zehaf-Bibeau was a familiar face on the Downtown Eastside.

He was an unusually quiet person who smoked “a lot of crack cocaine” and would lose his temper at the slightest provocation, according to someone who lived at the same shelter on East Cordova.

“He’d say the Middle East is going to take over the world, how much he hated the United States and Canada,” said Arthur Ranger, a former resident of The Beacon shelter. “I’d imagine they talked him into doing this pretty easily. He didn’t care about living or dying.”

Lauren Chan, a spokeswoman for the Salvation Army which runs the shelter, confirmed Zehaf-Bibeau used to be a resident, but would not give any further information, citing an ongoing police investigation.

Ranger said Zehaf-Bibeau usually kept to himself, but was easily provoked.

“He used to go off on people for stupid things ... if you bumped into him on the bus,” he said. “I think he had mental health issues. In fact, I’m almost positive he did.”

Other Downtown Eastside residents, who did not want to give their names, also recalled seeing Zehaf-Bibeau walking up and down East Hastings Street with a backpack and observed that he was a drug user.

He used to frequent the Native Health clinic and Oppenheimer Park, Ranger said.

He wasn’t sure when he had last seen Zehaf-Bibeau, but said it may have been as recently as a few months ago.

Investigators are trying to identify what motivated the 32-year-old gunman to shoot a reservist at the national war memorial and storm the parliament buildings.

In the days before, Michael Zehaf-Bibeau had been reading the online posts of a Canadian jihadist who recently urged his followers to “carry out attacks on Canada,” according to sources.

His online profile has turned up a link to Abu Khalid Al Kanadi, a Muslim convert and Islamic State of Iraq and Al-Sham member who has been urging attacks in Canada.

The two were not necessarily communicating directly with one other, but Zehaf-Bibeau was reading the repeated online incitement that Al-Kanadi posted on Twitter — until his account was suspended on Wednesday.

“Canada to send 10 aircraft and 600 soldiers joining the crusade against the Muslims,” Al Kanadi, who had worked in Alberta before departing for Syria, wrote on Oct. 7. “TRUE CDN MUSLIMS Fulfill your duty of jihad in Canada.”

RCMP Commissioner Bob Paulson told reporters on Thursday that Zehaf-Bibeau, whom he said may have been a dual Libyan-Canadian citizen, had lived in Vancouver, Montreal and Calgary before arriving in the capital three weeks ago.

“We have learned through the current investigation that this individual has been in Ottawa since at least Oct. 2nd, 2014, that he was in town to deal with a passport issue but that he was hoping to leave for Syria,” the commissioner said.

His passport application was held up after the RCMP was contacted to carry out background checks on the small-time criminal, who had convictions for drugs and violence.

“The RCMP did not possess information at that time that would reveal any national security-related criminality,” Comm. Paulson said.

Police had only “uncorroborated information” that he was associated with “an individual who is known to us.”

Zehaf-Bibeau was not one of the 90 high-risk travellers under RCMP investigation. “According to some accounts, he was an individual who may have held extremist beliefs.”

Using a car he bought Tuesday, Zehaf-Bibeau drove to the National War Memorial the next morning and fatally shot Cpl. Nathan Cirillo. He then drove to the Parliament buildings, where he was killed by security staff after running into Centre Block with a shotgun.

The commissioner said police had found no information linking Zehaf-Bibeau to Martin Rouleau, who on Monday ran down two Canadian Forces members with his car in Saint-Jean-sur-Richelieu, Que., before he was shot dead by police.

Rouleau was a follower of ISIS and had been arrested while attempting to leave for Turkey, possibly to join the terrorist group. Both men were recent Muslim converts and followers of online ISIS propaganda. “The investigation is ongoing and will rapidly determine if Zehaf-Bibeau received any support in the planning of his attack,” said Comm. Paulson.

Meanwhile, citing U.S. law enforcement sources, CNN reported that Zehaf-Bibeau had ties to several Canadian jihadists, including Hasibullah Yusufzai, a Burnaby man charged with terrorism for joining armed Islamists in Syria.

The link to Al-Kanadi may offer clues for investigators about Zehaf-Bibeau’s mindset. An ardent extremist, Al-Kanadi has claimed in online posts that he converted to Islam in 2010. He recently wrote that it would be acceptable to kill his own family members because they are not Muslims.

“God willing sharia (Islamic law) will eventually be applied in the West … in Canada,” he wrote. “Islam will dominate the world.” He has also defended ISIS beheadings, condemned democracy, and said ISIS will fly its flag over the White House.

On the social media site Ask.FM, he described himself as a “Caucasian white” born in Canada. When he left for Syria, his parents “reacted mainly with confusion, not understanding why someone would leave Canada to go to a land of war,” he wrote.

He uses the website, which allows followers to ask anonymous questions, to give advice to would-be jihadists, warning them not to tell anyone their plans and to avoid watching jihadi videos. Despite being only a recent convert, he berates Muslims for not joining ISIS in Syria. “Terrorism is a commandment from Allah,” he wrote.

But after Prime Minister Stephen Harper announced that Canada would be sending military advisers and CF-18 fighters to combat ISIS, he ramped up his incitement campaign.

“Canadians choose their policy makers. They then send their armies to kill Muslims. Allah has made it permissible to retaliate in a like manner. If you don’t support your government, leave your country. Better yet, enter Islam and come to the Islamic State.”

With files from Stewart Bell, Postmedia News

tcarman@vancouversun.com

Mhager@postmedia.com

Follow me: @MikePHager

mrobinson@vancouversun.com

Follow me: @atmattrobinson

===

Click here to report a typo or visit vancouversun.com/typo.

Is there more to this story? We'd like to hear from you about this or any other stories you think we should know about. CLICK HERE or go to vancouversun.com/moretothestory

===

VIEW MORE PHOTOS HERE, or if you're using a mobile app, tap the story image and swipe.

===