QUEBEC — In a world often hostile to migration, Canada has stood out, welcoming thousands of refugees fleeing war and seeking a haven. It has been a feel-good time for Canada, proud of its national tolerance.
On Sunday, that was upended when a man walked into a mosque and started shooting, killing six people and wounding eight. The man accused of being the gunman, Alexandre Bissonnette, was charged with six counts of murder on Monday.
The nation quickly rallied after the attack. Prime Minister Justin Trudeau called it an act of terrorism, and there was a collective outpouring of remorse and empathy. But the attack also forced Canadians to confront a growing intolerance and extremism that has taken root particularly among some people in this French-speaking corner of the country.
It was also a wrenching event for a country not accustomed to mass killings and even less used to the acrimonious immigration debate that has echoed from across the United States. Before Sunday, many Canadians were watching the immigration ban there with fascination and, for the most part, disgust.
“Muslim Canadians are valued members of every community and wherever they live they deserve to feel safe; they are home here,” Mr. Trudeau said at a memorial near the mosque in the Ste. Foy neighborhood in Monday evening’s biting cold. “We are all Canadians. Let peace unite us all.”
Yet while Canadian public figures of all stripes closed ranks quickly to reaffirm their solidarity with Muslims in Canada and tighten their embrace of multiculturalism, the killings remained a tear in the fabric of a nation in transformation.
“Canada took in roughly 30,000 Syrian refugees in a three-month period — proportionate to the U.S. taking in 225,000 over that time,” said David B. Harris, a lawyer and a director at Insignis Strategic Research, a counterterrorism consultancy. “These are dramatic developments in the life of any nation.”
Mr. Bissonnette, 27, who was also charged with five counts of attempted murder, appeared at the Quebec City courthouse looking boyish in a white jumpsuit. He was not charged with terrorism, which under Canada’s Criminal Code requires a broad proof of intent to intimidate the public.
The shooting was the first time anyone had been killed in a mosque in Canada in such circumstances and was, at least in recent times, a rare event outside the Muslim world. The attack was particularly shocking for Quebec City, where the bulk of the population of 750,000 works for the provincial government, universities or in tourism. Until Sunday there had not been any murders in the city for 21 months.
Mr. Bissonnette was well known to people who monitor far-right groups in Quebec, where he frequently commented on sites speaking about immigration and Islam. He was a particularly vocal supporter of Marine Le Pen, leader of France’s far right, when she visited the city last year.
He was a student of anthropology and political science at Laval University, just minutes from where the shooting took place, according to people who monitored his online activities.
“He was not a leader and was not affiliated with the groups we know,” said François Deschamps, a job counselor at Carrefour Jeunesse, a community organization that helps young people find jobs. Mr. Deschamps, who also runs an online group to help refugees called Bienvenue aux Réfugiés, said he had watched Mr. Bissonnette’s anti-Muslim postings for about a year.
“The minute I saw his picture this morning, I recognized him,” Mr. Deschamps said by telephone, adding that Mr. Bissonnette used his real name online.
Mr. Bissonnette and his family live in Cap-Rouge, a western suburb of Quebec City that lies in the shadow of a towering railroad trestle. Neighbors said there was nothing remarkable about the quiet young man.
“We knew the family for 30 years,” said Alain Dufour, a neighbor. He said Mr. Bissonnette and his brother were “normal kids, nothing indicating bizarre behavior.”
Even outspoken critics of the religion recoiled at the prospect that an increasingly acrimonious debate over rising Islamic immigration may have contributed to the violence.
Kellie Leitch, a conservative member of Parliament who has proposed screening immigrants for “Canadian values,” issued a statement calling the attack “not just on those gathered in a house of worship but on the very fabric of Canadian society.”
Quebec has had a history of confrontations with the Muslim community. In 2005, the province became the first to explicitly ban the use of Shariah law and, less than a decade later, the Parti Québécois government tried to pass a “charter of values” that would have banned provincial employees from wearing Muslim head scarves and other “overt” religious symbols.
Quebec City, meanwhile, is a conservative bastion within the province and home to right-leaning radio talk shows that push an anti-Islam agenda — unusual for Canadian broadcasters.
Lise Ravary, a columnist for the tabloid Journal de Montreal, said it might be time for the debate to calm down.
“I am a very vocal opponent of Islamism, and I realize now that whenever I condemn ISIS a lot of people view this as me condemning every Muslim on earth,” she said by telephone on Monday. “Self-censorship looms for the common good.”
Mohammed Amin, in charge of social activities at the mosque, said the community had a “cordial relationship” with its neighbors. He dismissed the pig’s head that was left at the mosque’s door last year as “a small incident” that could happen anywhere.
But other leaders at the mosque said there have been hate letters, and swastikas painted on its door, episodes that led to the installation of eight security cameras.
“We’ve had to be very, very vigilant, careful for our community,” said Boufeldga Benabdallah, a co-founder of the mosque. Of the victims, he said, “The prayed beside us and they were shot in the back because they prayed.”
Ste. Foy, the postwar suburb where the attack occurred, is far from the walled city center, which is stuffed with historic buildings and tourists.
The victims came from a variety of countries of origin and occupations. Azzeddine Soufiane, 57, was a butcher with a shop down the street from the mosque. Khaled Belkacemi, the oldest victim at 60, was a professor of soil and agri-food engineering at Laval University, according to members of the mosque.
Mamadou Tanou Barry, an information technology worker, and Ibrahima Barry, a provincial public servant, were brothers, Radio-Canada reported. Aboubaker Thabti, 44, came to Canada in 2011 from Tunisia and had two children. A programming analyst with the provincial government, Abdelkrim Hassane, 41, was father to three daughters.
“Certainly Islamophobia has been increasing for some time,” Samer Majzoub, president of the Canadian Muslim Forum, said by telephone from Montreal.
But he said the attack was nonetheless shocking. “It is overwhelming, unthinkable,” he said.