The Duke of Cambridge has been appointed Lord High Commissioner to the General Assembly of the Church of Scotland by the Queen for the second year in a row.
William was given the role as the sovereign's representative in 2020, but the week-long annual General Assembly in Edinburgh last May was cancelled because of the pandemic.
The Queen approved the appointment, which was announced by Downing Street on Monday.
The decision is made on the advice of Scotland's First Minister Nicola Sturgeon and Prime Minister Boris Johnson.
It comes at a crucial time for the UK's union, with the Scottish Government publishing a draft Bill for a second vote on independence.
Second in line to the throne William is taking on the role this year in the wake of the furore generated by the Duke and Duchess of Sussex in their interview with US chat show host Oprah Winfrey.
Harry and Meghan accused the royal family of racism and the institution of failing to help the suicidal duchess.
The Sussexes were stripped of their royal patronages and Harry's honorary military roles by the Queen in February when Megxit was confirmed as permanent.
William will travel to Scotland in May to host the online event in person - as one of the principal officers - at the General Assembly Hall in Edinburgh.
The commission granted by the Queen is specific to Scotland so the Lord High Commissioner must be present in Scotland to perform the role.
William, known as the Earl of Strathearn in Scotland, will also make the opening and closing addresses at the Assembly and carry out a number of official functions as the Lord High Commissioner, and also report to the Queen on the proceedings.
Monarchs have sworn to maintain the Church of Scotland since the 16th century.
The duty to "preserve the settlement of the true Protestant religion as established by the laws made in Scotland" was affirmed in the 1707 Act of Union between England and Scotland.
The Queen made this pledge at the first Privy Council meeting of her reign in February 1952.
The Church of Scotland is a Presbyterian church and recognises only Jesus Christ as "King and Head of the Church", so the Queen attend services as an ordinary member.
The Queen appoints a figure to the role every year, and previous royal family members who have carried out the duty include the Princess Royal, the Prince of Wales, the Duke of York and the Earl of Wessex.
In April, William wrote to the Right Reverend Colin Sinclair, the outgoing moderator of the Assembly, praising the work of the Church of Scotland.
"It is heartening to see how the Church of Scotland, like so many other faith communities across the country, is re-inventing itself digitally to continue providing worship, support and guidance for your congregations," the duke said.