Sunlight streamed through the stained-glass windows of St Giles’ Cathedral in Edinburgh as eight kilted soldiers from the Royal Regiment of Scotland carried her coffin with consummate care onto a decorated wooden frame.
The King, the Queen Consort and other members of the royal family then walked to their seats, less than 10ft from the oak coffin.
It was dressed in the Royal Standard of Scotland and was topped with a wreath which included Balmoral heather.
Charles took his place with his wife to his left and the Duke of York to his right.
The Princess Royal and her husband Vice Admiral Sir Tim Laurence sat to the King’s left and the Earl and the Countess of Wessex to his right.
The Duke of Hamilton, the most senior peer in the country, climbed three wooden steps and placed the Crown of Scotland on the coffin.
The Queen had long links with the High Kirk – this was the place where she attended a Service of Thanksgiving for her Coronation in 1953 and it houses the Thistle Chapel, home to Scotland’s highest chivalry order, The Order of the Thistle.
Opening the service, the Rev Calum MacLeod reminded the congregation who came from different sections of society including her staff, the emergency services, Armed forces and politics of the great history of the cathedral, first built 900 years ago.
He said: “So, we gather to bid Scotland’s farewell to our late monarch, whose life of service to the nation and the world we celebrate.
“And whose love for Scotland was legendary.”
Ms Sturgeon, who was sat close to the Prime Minister, gave a reading from Ecclesiastes, which begins “For everything a season” and reminds us that “all should eat and drink and take pleasure in all their toil”.
The current leaders of the Scottish political parties were there, as well as veterans of politics like Alex Salmond and Lord Steel.
Prayers were said to thank God for the life of the Queen and the service celebrated her love of Scotland.
In his homily, Rt Rev Dr Iain Greenshields said: “Much has been said about the Queen’s contribution to the life of the United Kingdom and the Commonwealth which meant so much to her.
“But here in Scotland we acknowledge with gratitude her deep links with our land and its people.
“Her love of the Balmoral estate is well known and being there latterly brought her great comfort.
“There she was valued as a neighbour and friend, and there she drew strength and refreshment during the summer months.
“She was active in the life of civic Scotland, travelling across the country to support numerous causes, entertaining guests at Holyrood Palace, and presiding at ceremonial events, many of which took place in this church.”
Incorporated in the service were the Psalms she would have sung on Sunday mornings at Crathie Kirk in Balmoral.
As the service drew to a close, four suited members of the Royal Company of Archers, dressed in long-feathered hats and armed with arrows and quivers, stood guard beside the Queen.
Members of the congregation bowed and curtseyed as they made their way past the coffin, which will stay in place until Tuesday evening.
Applause could be heard when the King and his family stepped out into the Edinburgh sunshine, in front of huge crowds flocking the Royal Mile.