Suspect Alexandre Bissonnette, who was also charged with five counts of attempted murder, made a brief court appearance and did not enter a plea.
Wearing a white prisoner jump suit, his hands and feet shackled, he stared down at the floor and fidgeted, but did not speak.
The attack left six people dead during evening prayers on Sunday, and Canada’s prime minister Justin Trudeau called it an act of terrorism against Muslims.
The 27-year-old suspect has supported the French far-right party of Marine Le Pen and had liked US President Donald Trump on his Facebook page.
He was known to those who monitor extremist groups in Quebec, said Francois Deschamps, an official with a refugee advocacy group.
He wrote on the Facebook page of the group, Bienvenues aux Refugies, or Welcome to Refugees, that Bissonnette was “unfortunately known to many activists in Quebec for taking nationalist, pro-Le Pen and anti-feminist positions at Laval University and on social media”.
An anthropology and political science major at Laval University in Quebec City, Bissonnette had also expressed support on his Facebook profile for “Generation Nationale,” a group whose manifesto includes the rejection of “multiculturalism”.
More than 50 people were at the Quebec Islamic Cultural Centre when the shooting erupted.
In addition to the six dead, 19 men were wounded. Of the five victims who remained in hospital, two were in critical condition. The dead ranged in age from 39 to 60.
Mr Trudeau and Quebec Premier Philippe Couillard both characterised the attack as a terrorist act, which came amid heightened tensions worldwide over Mr Trump’s travel ban on seven Muslim countries.
Ms Le Pen, leader of the National Front in France, is known for her anti-Muslim, anti-immigrant positions and has won the endorsement and admiration of white supremacists.
Canada is generally welcoming toward immigrants and all religions, but the French-speaking province of Quebec has had a long-simmering debate about race and religious accommodation.
The previous separatist government of the province called for a ban on ostentatious religious symbols, such as the hijab, in public institutions.
Mr Trudeau said in Parliament that the victims were targeted simply because of their religion and spoke directly to Muslims who live in Canada, saying: “We are with you.”
He said: “Thirty-six million hearts are breaking with yours. Know that we value you.”
The prime minister later attended a vigil outside the mosque.
The suspect was arrested in his car on a bridge near d’Orleans, where he called 911 to say he wanted to co-operate with police.
The authorities, who initially named two suspects, said the other man taken into custody was a witness to the attack and was released earlier on Monday.
Mr Trump called Mr Trudeau to express condolences to the Canadian people and to offer any assistance that might be needed.
The White House pointed to the attack as an example of why Mr Trump’s policies were needed.
“We condemn this attack in the strongest possible terms. It’s a terrible reminder of why we must remain vigilant and why the president is taking steps to be pro-active, rather than reactive when it comes to our nation’s safety and security,” White House spokesman Sean Spicer said.
The victims were businessmen, a university professor and others who had gathered for evening prayers, said Mohamed Labidi, the vice president of the mosque.
He said the victims were shot in the back: “Security at our mosque was our major, major concern. But we were caught off guard.”
The shooting took place just before 8pm on Sunday. Witnesses described chaos as worshippers scrambled to find friends and loved ones, with police who responded to the scene calling for backup.
The mosque has been a target of hate crimes in the past, including last summer when a pig’s head was left on its doorstep during Ramadan.