Prince William has spoken of the Church as a place of refuge during the pandemic and in his own life following the death of his mother, Princess Diana.
Addressing the General Assembly of the Church of Scotland on Saturday morning, the Duke of Cambridge said: "I know that for many people across Scotland and beyond, the Church has been an essential refuge over the past incredibly challenging year of the pandemic."
He also spoke of the comfort he had found in attending church near the Balmoral estate in Scotland on the day he learned that his mother had died.
"I was in Balmoral when I was told that my mother had died," he said.
"Still in shock, I found sanctuary in the service at Crathie Kirk that very morning, and in the dark days of grief that followed, I found comfort and solace in the Scottish outdoors.
"As a result, the connection I feel to Scotland will forever run deep."
Although this was a "painful memory" for the Duke, he spoke of another that brought "great joy" - meeting his wife, Kate Middleton, 20 years ago as a student at St Andrew's University.
"Needless to say the town where you meet your future wife holds a very special place in your heart. George, Charlotte and Louis already know how dear Scotland is to both of us and they are starting to build their own happy memories here too," he said.
The Duke attended the Church of Scotland General Assembly as Lord High Commissioner, representing the Queen.
The Duke and Duchess are in Scotland on a weeklong visit that will include meetings with charities and organisations working on issues like the environment, mental health, homelessness and addiction.
"As we try to emerge from a long period of uncertainty and turmoil, I'm grateful for the chance I'll get this week to really listen with humility and compassion to many people in Scotland from all walks of life, from different traditions and from all faiths and none," the Duke continued.
"It has been suggested I take Proverbs 19:20 as my guide - 'Listen to advice and accept instruction, that you may gain wisdom in the future.' And of course, Jesus himself put it more succinctly: 'Those who have ears, let them hear.'
"I know all of these issues and many more will form part of your deliberations in the General Assembly this week. I wish you all the very best for these discussions and I look forward to hearing your conclusions and sharing some of my own reflections during the closing ceremony."