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 space was.

“I’m here to help you show the world that he failed.”

William visits Christchurch attack mosque
William meeting families at the mosque in Christchurch )New Zealand Department of Internal Affairs/PA)

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.

“Grief, if you let it, will reveal who you are. It can 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 your wells of empathy, compassion, warmth and love truly 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 of compassion and resolve” in the wake of the shootings.

New Zealand Prince William Mosque Attacks
William was accompanied by prime minister Jacinda Ardern (wearing a cream-coloured headscarf on the right) (Joseph Johnson/Pool via AP)

Farid Ahmad, who lost his wife Husna Ahmad in the attack on the Al Noor mosque, 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.

William later travelled for a private visit to Linwood mosque, which was also attacked.

A total of 50 people were killed in the shootings at the two locations, while dozens more were injured.

Earlier on Friday, William visited Christchurch Hospital to meet the staff who had helped save some of the wounded.

Hospital chiefs have previously told how surgeons and staff worked through the night to treat the injured.

New Zealand Prince William Mosque Attacks
William was received by Imam Gamal Fouda (Joseph Johnson/Pool Photo via AP)

William also met five-year-old survivor Alen Alsati on the first day of his visit, after the youngster 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.

Concluding his brief visit to New Zealand, William laid a wreath at the Oi Manawa Canterbury Earthquake National Memorial before meeting members of the public who had turned out to greet him.

He spent about half an hour chatting to the cheering crowd before leaving with a smile and a wave.

Throughout his visit, those who have met him have told how he has brought great comfort and reassurance to people of New Zealand in their time of need.