CHRISTCHURCH, New Zealand — Lamenting that “the world has been stuck in a vicious cycle of extremism breeding extremism,” Prime Minister Jacinda Ardern of New Zealand said at a national memorial service for the Christchurch attack victims on Friday that the dangerous cycle “must end.”

Ms. Ardern’s call for a collective global response to violence and terrorism — based in “our humanity” — came two weeks after a gunman killed 50 worshipers in attacks on two mosques in the city.

Her speech reflected questions that New Zealanders have been wrestling with as the shock of the attack has begun to fade: namely, how deeply extremist sentiments have taken root in the country, and how to prevent such violence from happening again.

“The ugliest of viruses can exist in places they are not welcome,” Ms. Ardern said, adding that racism, violence, extremism and assaults on freedom of worship were “not welcome here.”