QUEBEC CITY (Reuters) - A Canadian man who gunned down six members of a Quebec City mosque in 2017 was sentenced to life in prison on Friday, with the judge saying he would be eligible for parole after serving 40 years behind bars.

Alexandre Bissonnette, a suspect in a shooting at a Quebec City mosque, arrives at the court house in Quebec City, Quebec, Canada February 21, 2017. REUTERS/Mathieu Belanger

Alexandre Bissonnette, 29, pleaded guilty last year to six counts of first-degree murder and six counts of attempted murder for the attack, one of Canada’s rare mass shootings.

Justice François Huot said a life sentence with eligibility for parole between 35 and 42 years into the sentence was appropriate, and rejected calls by prosecutors to impose the harshest sentence handed down since Canada eliminated the death penalty.

In the end, the judge said Bissonnette will not be eligible for parole until he served 40 years of his sentence.

The January 2017 shooting, which Prime Minister Justin Trudeau denounced as a terrorist attack, provoked debate over the treatment of new arrivals at a time when Canadians were being tested by a growing number of migrants crossing from the United States into the province of Quebec.

Huot said Bissonnette’s actions in entering the mosque at the end of prayers and shooting congregants were not a terrorist attack, but motivated by prejudice, particularly toward Muslim immigrants.

But the judge also said Bissonnette’s mental health issues, including an obsession with suicide, played a role in the shooting and influenced his sentence.

A 2011 legal change allows Canadian judges to hand down consecutive sentences in the case of multiple murders. Prosecutors had asked for Bissonnette to serve six consecutive sentences or 150-years in prison without eligibility for parole, the harshest sentence since Canada abolished the death penalty in 1976.

“The U.S. Supreme Court would not find a 150-year (term) cruel and unusual punishment,” Huot said earlier in the day, but added “punishment should not be vengeance.”

Huot also stressed the importance in Canada of rehabilitating offenders.

The dark-haired, slightly-built Bissonnette, who wore a white shirt under a navy blue jacket and handcuffs, had been described by police as a lone-wolf attacker.

Bissonnette had previously asked his victims for forgiveness when entering his guilty plea in March, telling the court: “I am not a terrorist, nor an Islamophobe.”

But Huot said Bissonnette had previously considered attacking other targets including feminists, shopping centers and airports. The judge recounted Bissonnette’s remarks to a prison social worker in Sept. 2017, when he expressed a desire for “glory” in shooting congregants and that he “regretted not shooting more.”