Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A 27-year-old college student was charged Monday with the shooting at a Canadian mosque that the prime minister declared "a despicable act of terrorism."

Alexandre Bissonnette, described as a loner with anti-immigrant views, was expected to appear in court to face six counts of murder and five counts of attempted murder.

A second man who was detained after the attack on the Quebec City Islamic Cultural Center, where six people were killed and 17 others were injured, is considered a witness and not a suspect. Police said they are confident there was only one shooter.

Alexandre Bissonnette is escorted to a van after appearing in court for Sunday's deadly shooting at a mosque, on Jan. 30, 2017, in Quebec City. Jacques Boissinot / The Canadian Press via AP

Police have said one of the two men was arrested after he called 911 to say he was in his car on a bridge near Île d'Orléans, an island in the Saint Lawrence River, and was armed and ready to surrender, officials said.

More than 50 people were in the mosque at the time of the attack. Laval University, where Bissonnette was a student, identified one of the victims as an agriculture professor, Khaled Belkacemi, 60. The others were Mamadou Tanou Barry, 42; Abdelkrim Hassane, 41; Aboubaker Thabti, 44; Azzeddine Soufiane, 57; and Ibrahima Barry, 39.

"This was a group of innocents targeted for practicing their faith," Prime Minister Justin Trudeau told the House of Commons on Monday afternoon.

"Make no mistake: This was a terrorist attack."

Professor Khaled Belkacemi was killed in the mosque shooting. via INAF

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

No more information has been released about the motive. In June, a pig’s head was left on the doorstep of the Quebec City Islamic Cultural Center, but it was not known whether the incident was related in any way.

A former classmate of Bissonnette's told NBC News that he was shocked by the arrest but said that the suspect was known to troll Facebook pages dealing with immigration issues and that he had seen him comment on pages linked to a far-right, nationalist, anti-immigration movement. A local refugee group said in a Facebook post that Bissonnette was known to it for anti-immigrant and anti-feminist stances.

"His online life was full of hate, but in real life he was calm and his chess game was on point," said Antoine Cabanac, the former classmate, who went to high school and pre-university with Bissonnette and was in the chess club with him.

Bissonnette's Facebook page said he had studied political science and anthropology at Laval University. There were photos of him at a party, with family, in a Halloween costume and posing in front of a chessboard. He had liked pages for heavy metal bands, video games and public figures ranging from far-right French politician Marine Le Pen and U.S. President Donald Trump to chess grandmaster Anatoly Karpov and Pope John Paul II.

Among the posts he had liked in recent months: a June posting on another person's page that read: "We live in a world where Christianity is demonized over cake and Islam is defended despite 50 dead at a gay club. Amazing."

A neighbor, Regern Bessière, told NBC News that Bissonnette liked to play with guns in the woods behind his house and talked about violent videos he watched.

"He wasn't sociable," he said. "He kept to himself."

Police patrol the scene of a fatal shooting at the Quebec Islamic Cultural Center in Quebec City. Mathieu Belanger / Reuters

"We were surprised by this event, especially because there's a strong relationship between Quebec City and Muslim communities," Chiheb Ayed, a congregant of the Centre Culturel Islamique de Quebec, told NBC News on Monday night.

Ayed, 39, who has been living in Quebec City for 16 years, said he, his wife and other Muslims in Quebec City were reaching out to help families waiting for answers on their loved ones.

"Many of them don't have much family or friends here. In Quebec City, it's not a big community of Muslims, so we try to help each other," he said.

Trudeau, who received a condolence call from Trump, issued a call for unity.

"Such senseless violence has no place in Canadian society," he said. "Canada has long been a diverse and accepting nation. We are kind. We are generous. We embrace one another not in spite of our differences but because of them.

"Canadians will not be broken by this violence," he said.

While police in Quebec City didn't say whether they believed the shooting was motivated by Islamophobia, officials in New York City said they were beefing up security at mosques and other religious locations.

Incidents of Islamophobia have increased in the province of Quebec in recent years, according to Reuters.

Sunday's attack came hours after Trudeau openly rejected Trump's restriction on travel from seven majority Muslim nations.

To those fleeing persecution, terror & war, Canadians will welcome you, regardless of your faith. Diversity is our strength #WelcomeToCanada — Justin Trudeau (@JustinTrudeau) January 28, 2017

Trump's executive order has sparked protests across the United States and beyond. And while he didn't directly reference the demonstrations, Quebec Premier Philippe Couillard echoed the protesters' sentiments at a news conference Monday morning.

"We should not withdraw and become a closed society because of such a terrible event," he said. "On the contrary, as I indicated, we have to keep working together, striving towards an open, inclusive, peaceful society. That's the right response to this terrible event."

"We are all Quebecois ... a big nation even more united today," Couillard said.