All those in the procession walked in step, moving from side to side as one, within touching distance of the coffin draped with the Royal Standard of Scotland with a wreath of Balmoral flowers on top.
The Right Reverend Doctor Iain Greenshields, moderator of the General Assembly of the Church of Scotland, delivered the homily during the thanksgiving service attended by Prime Minister Liz Truss, who has joined the new king during his tour of the four home nations to receive messages of condolence in person.
He said about the queen: "She was determined to see her work as a form of service to others, and she maintained that steady course until the end of her life."
The senior minister added: "And although sometimes buffeted by events around her, she continued resolutely and cheerfully to fulfil her responsibilities. And so today we give thanks not only for the length of her reign but for the qualities she displayed so steadfastly."
When the new king addressed peers and MPs in London, Charles said: "I am deeply grateful for the addresses of condolence."
He said the addresses "touchingly encompass what our late sovereign, my beloved mother the queen, meant to us all."
Charles once again reached for Shakespeare, after quoting from the play "Hamlet" in his address to the nation last week.
"As Shakespeare says of the earlier Queen Elizabeth, she was 'a pattern to all princes living.'
"As I stand before you today, I cannot help but feel the weight of history which surrounds us and which reminds us of the vital parliamentary traditions to which members of both houses dedicate yourselves with such personal commitment, for the betterment of us all."
The queen's coffin will remain at St Giles' Cathedral for a 24-hour period before being flown to London on Tuesday evening ahead of the monarch lying in state at Westminster Hall from Wednesday, before the state funeral next Monday.