Cries of "Vive le Québec!" mingled with "Allahu Akbar!" in a rare display of unity as Muslims and their more secular neighbours asked for civic engagement and God's mercy at the funeral for three of the six men killed while praying last Sunday.

Several thousand mourners filled a Montreal hockey arena transformed into a temporary mosque Thursday for the funerals of the men shot at their own place of worship in Quebec City by a lone gunman.

The Montreal venue for the funerals was partly a matter of expediency. Autopsies for the victims took place in Montreal and three of the men wished to be buried in their North African homelands. Their remains were to be flown out within hours of the service for the expedient burial called for by the Islamic faith.

Story continues below advertisement

In Photos: Hundreds gather in Montreal for funeral service of three Quebec City mosque victims

Related: 'I won't be scared of praying here': Quebec City mosque reopens for worship

Read more: Worshippers open doors to attacked Quebec City mosque, share their sorrows

The place was also filled with symbolism as imams prayed incantations in the arena named for one of the province's secular saints, hockey icon Maurice Richard. The location also gave people in Montreal – where the majority of Quebec's Muslims live – a chance to mourn their collective loss.

Goodwill has its limits, however. The city has seen a spike in hate crimes since the bloody attack and as mourners lined up, across town in the neighbourhood of Point-St-Charles, a mosque was vandalized with eggs and had a window broken.

There was no room for hate at the rink. Dozens of police officers and private security used a light and respectful hand as they asked mourners to open their bags and parkas at the arena entrance in the city's east end. They lined up around the block and streamed in for nearly two hours and the service started a half hour late to accommodate the crowd.

Mourners filled the covered ice surface and paused at the foot of the coffins of Khaled Belkacemi, Abdelkrim Hassane and Aboubaker Thabti.

Story continues below advertisement

After traditional prayers from the Koran that echoed across the arena, Prime Minister Justin Trudeau paid tribute to each of the men. Mr. Belkacemi, Mr. Trudeau noted, was more than a teacher for his Laval University students. He was also an upstanding man who looked after his students inside and outside class. The Prime Minister said Mr. Hassane came to Canada to guarantee a better future for his three daughters. Mr. Thabti was a man of devotion and love, he said.

"Their dreams were the same of Canadians across the country for generations. To give their children a better life," Mr. Trudeau said. The six men killed Sunday left behind 17 children.

Quebec Premier Philippe Couillard, who was omnipresent this week reinforcing a message of solidarity, opened his remarks with an Arabic salutation and urged Muslims to stay strong.

"To our Muslim brothers and sisters, you must know you are home. We are all Quebeckers," he said, triggering a spontaneous shout of "Vive le Québec!" from a woman wearing a hijab in the crowd. "Yes, Vive le Québec!" Mr. Couillard replied to sustained cheers. Cries of "Allahu Akbar" (God is Greatest) also filled the cavernous rink.

Several Muslim religious leaders and diplomats from the men's home countries also spoke.

Mohamed Yangui, the president of the mosque that was attacked, urged non-Muslims to avoid lumping in rare extremists with the wider Muslim community. "We are not terrorists," he said. "We are not these terrorists who hide behind a veil of Islam."

Story continues below advertisement

However, Mr. Yangui noted the glimmer of hope that has emerged from the bloodshed. "In all this darkness, this sliver of light, of solidarity, that shows the Quebec community is tight and unified."

Each coffin was draped in the national flag of each man's country of origin. After the funeral, the remains of Mr. Thabti, 44, were to be flown to Tunisia while those of Mr. Belkacemi, 60, and Mr. Hassane, 41, were to be returned to Algeria.

"I am very sad and at the same time very angry to know that one of our own did this mad gesture," said Bernard Morin, a retiree from Montreal, as he waited in line. "We have a lot of questions to ask and answers to find."

Fatima Choulak said she took the metro from the suburb of Longueuil to offer her "support and solidarity with these widows, these 17 orphans who are suffering terribly."

Nicolas Lemieux, a Quebec City native who was a friend of Azzeddine Soufiane, who was among the six dead, said he wanted to pay his respects to reinforce the message that the men "were citizens just like me."

Montrealer Razibul Haque says Muslims live in peace in Canada but anti-Muslim sentiment is growing and has to be reversed. "I wonder if the things going on in the United States are infecting Canada," he said. "I hope we can live in peace."

Story continues below advertisement

Alexandre Bissonnette, 27, faces six charges of first-degree murder in the assault, which authorities have described as an act of terror. Police have not revealed a motive for the crime but the suspect's acquaintances say he held virulent anti-immigrant and Islamophobic views.

A funeral for Mamadou Tanou Barry, 42, and Ibrahima Barry, 39 and Mr. Soufiane, 57, will be held Friday in Quebec City.