The couple sat down for talks with the former prime minister and his wife Sarah at the Queen’s official Edinburgh residence.
William later gave a highly personal farewell speech as his week-long tour drew to a close, describing how Scotland has “shaped” him and praising its people and values.
The argument over Scottish independence has intensified after the Scottish National Party’s landslide victory in the Holyrood election in May, which also produced the largest pro-independence majority in the Parliament in the history of devolution.
Boris Johnson has since stood by his pre-election position, saying the focus should be on the recovery from Covid-19 and not on another independence referendum.
Last month, a spokesperson for Kensington Palace said: “During his time in Scotland Prince William has spoken to a broad range of people from different communities including politicians from across the political spectrum.”
The duke sat down for talks with First Minister Nicola Sturgeon and also met Alistair Carmichael, Liberal Democrat MP for Orkney and Shetland.
Soon after the Holyrood election Mr Brown announced his Our Scottish Future think tank which will become a “campaigning movement” seeking to appeal to “middle Scotland”, those who are not entrenched in their positions on the union or independence.
Speaking in Edinburgh at the closing ceremony of the General Assembly of the Church of Scotland, William said about some of the memorable individuals he had met.
He said: “These people make Scotland the vibrant, friendly, innovative and determined place Catherine and I love, and is so important to us.”
The duke who is the assembly’s Lord High Commissioner added: “I’m shaped by this place.
“The abiding affection I feel for it is rooted in my experience of its everyday life in people, relationships, and its ethic of neighbourliness.”
Meanwhile, the couple released a video on their YouTube channel earlier this week recapping their tour.
They wrote in a caption alongside the video: “To the people, communities and organisations we visited and heard from; and those who stopped to wave and make our return to Scotland so special – thank you.”