New Zealand has shown the world it will not be divided in the wake of the devastating Christchurch mosque shootings, the Duke of Cambridge has said.
In a moving speech at the Masjid Al Noor in Christchurch, where 42 people lost their lives, William hailed the example set by the country as it continues to come to terms with the tragedy.
"On the 15th of March, tragedy unfolded in this room," he said.
"A terrorist attempted to sow division and hatred in a place that stands for togetherness and selflessness.
"He thought he could redefine what this place was.
"I'm here to help you show the world that he failed."
Describing the shootings as an "unspeakable act of hate", the duke said he "couldn't believe the news" when he woke up on the morning of March 15.
But he praised those who rushed to help, those who dropped everything and put their own lives on the line to save others, and those who were there for people in their time of need.
"To the people of New Zealand and the people of Christchurch - to our Muslim community and all those who have rallied to your side: I stand with you in gratitude for what you have taught the world these past weeks," he said, adding that people of all faiths and backgrounds could learn from their example.
He also hinted at his own grief following the death of his mother Diana, saying: "I've had reason myself to reflect on grief, sudden pain and loss in my own life.
"What I've realised is that of course grief can change your outlook, you don't forget the shock and sadness or pain, but I do not believe grief changes who you are.
"If you let it, it will reveal who you are. It will reveal depths you did not know you had.
"This is what happened here. An act of violence was designed to change New Zealand, but instead the grief of a nation revealed just how deep the values of warmth, compassion and love really run."
New Zealanders had "other plans" than falling victim to the division the terrorist hoped to sow, he added.
"In a moment of acute pain, you stood up and you stood together. In reaction to tragedy you achieved something remarkable," he said.
William also hailed prime minister Jacinda Ardern, who has drawn worldwide praise since the attacks, for showing "extraordinary leadership and compassion" in the wake of the shootings.
Farid Ahmad, who was injured during the attack on the Al Noor mosque and lost his wife Husna Ahmad, broke down as he welcomed William.
"Right now my heart is aching," he said. I'm feeling the pain. I lost my wife, I lost many people here.
"I would like to say to the victims, you are not alone. We share your pain and we are together."
"Your royal highness, you are an inspiration for the world," he added.
"We pray for you, that may Allah make you a shining light to inspire people in the world towards peace, security and safety and hope."
Outside the mosque, where dozens of floral tributes provide a visual reminder of the solidarity shown in the wake of the attacks, members of the Muslim community told of the comfort the duke's visit had brought.
Children played freely on the grass, where just weeks earlier unimaginable horror had unfolded during a peaceful moment of prayer.
Earlier on Friday, William visited Christchurch Hospital to meet the staff who helped save lives in the aftermath of the tragedy.
Hospital chiefs have previously told how surgeons and staff worked through the night to treat the dozens of people who were injured when a gunman opened fire during Friday prayers.
William has also met five-year-old Alen Alsati during his visit, who was injured in the shootings and awoke from a coma earlier this week.
Kensington Palace shared a video of a touching moment between the pair during the private meeting at Starship Children's Hospital in Auckland.
The Duke of Cambridge meets five year old Alen Alsati, who is recovering in Starship Children’s Hospital in Auckland after being injured in the Christchurch mosques terrorist attack.— Kensington Palace (@KensingtonRoyal) April 25, 2019
Alen woke from a coma earlier this week after suffering critical injuries in the attack. pic.twitter.com/XcNAsIw7xt
Later, the duke is due to meet members of the public during a walkabout in the city centre as he concludes his brief visit.
On Friday, New Zealand police commissioner Mike Bush told how William had offered up his support to those who put their lives on the line to save others after the terrorist attack.
Speaking after the duke met officers, medics and first responders at the city's Justice and Emergency Services Precinct, Mr Bush described how the "emotion was palpable" as William found out more about how the attacks unfolded.
"If I could use the words he used to our staff, 'a good friend doesn't pick up the phone when a person is in need - they travel to their place and put their arms around them'," he said.