The man who killed six Muslims in a Quebec City mosque last year as they attended prayer sought forgiveness Wednesday for his acts and said it was "as though I was battling a demon that finished by winning out."

"Every minute of my existence I bitterly regret what I did, the lives I have destroyed, the pain and suffering I have caused to so many people, without forgetting the members of my own family," Alexandre Bissonnette said as he read out a letter in court.

"I am ashamed of what I did."

Bissonnette, 28, spoke to the court shortly after a judge accepted his guilty pleas on six charges of first-degree murder and six of attempted murder in connection with the attack.

Many people in the courtroom burst out sobbing and held hands as the judge confirmed the guilty pleas.

Bissonnette originally pleaded not guilty to the 12 charges Monday morning but announced that afternoon he was changing his mind and wanted to plead guilty.

Superior Court Justice Francois Huot originally refused to accept the pleas pending a psychiatric assessment of the accused to ensure he fully understood the consequences of his decision.

Huot placed a publication ban on Monday afternoon's proceedings but agreed Wednesday to accept the guilty pleas.

In reading his letter, Bissonnette said he had been "overcome by fear, by negative thoughts and a sort of horrible kind of despair" before the shootings.

"It's (as) though I was battling a demon that finished by winning out...I would like to ask for forgiveness for what I did, but I know my acts are unforgivable."

The charges against Bissonnette were related to a shooting attack at the Islamic Cultural Centre in January 2017 in which he killed six men: Mamadou Tanou Barry, 42; Abdelkrim Hassane, 41; Khaled Belkacemi, 60; Aboubaker Thabti, 44; Azzeddine Soufiane, 57; and Ibrahima Barry, 39.

Psychiatrist Sylvain Faucher, who met with Bissonnette on Monday evening, said he was "fit to stand trial and to plead what he wants to plead."

"He did not want to be the perpetrator of another collective drama," said Faucher.

On Monday, Bissonnette said he wanted to plead guilty in order to "avoid a trial and for the victims to not have to relive this tragedy."

The counts of attempted murder involved five people who were struck by bullets and a sixth charge encompassed the other people present at the mosque.

Many members of Quebec City's Muslim community were present in court Monday and Wednesday.

"That the trial won't have to take place, it's a good thing for us, it's a good thing for everyone in the community," Amir Belkacemi, Belkacemi's son, told reporters.

"Very relieved."

Asked why, Belkacemi said that what happened 14 months ago is still very fresh in people's minds.

"I think the events that took place last year are very traumatic, very difficult," he said. "No one really wants to live those traumatic days again, and today what happened in the courtroom kind of puts it to an end."

Bissonnette told Huot on Monday he had been thinking for sometime of pleading guilty but that he was missing certain pieces of evidence, which were relayed Sunday.

When Huot asked him if he was fully aware of what he was doing, Bissonnette replied, "Yes."

He also said he was not changing his pleas because of any threats and that he was not under the influence of alcohol or drugs.

Huot asked Bissonnette whether he knew he would be getting a life sentence and he answered, "I understand."

Huot also asked him if he understood he could receive consecutive sentences, meaning 150 years of prison.

"I know," Bissonnette replied, in a low voice.

Sentencing arguments will take place at a later date.

Jury selection had been scheduled to start April 3 and the trial to last two months.

It sure would be nice to know what factors caused him to go to a place of such fear and such negative thoughts. I had read when this horror first happened he had been influenced or emboldened by Trump style supporters. Was this man watching the hateful Fox news? There are stories on the internet of people observing their elderly relatives becoming hateful and fearful after watching certain parts of Fox news.

Then explain why you were going to plead not guilty. Explain. Don't just insult with vacuous rambling.

(Or is the reporter cutting stuff out?)