The Queen met with members of the armed forces during an act of loyalty parade in Edinburgh as part of Holyrood week.
The ceremony took place in the gardens of the Palace of Holyroodhouse on Tuesday to celebrate her visit to Scotland and to mark her Platinum Jubilee.
The 96-year-old arrived in the gardens smiling and wearing a heather-coloured silk wool dress and coat with a matching hat, all by Angela Kelly.
They were joined by three cadets, representing each service.
The key to the castle was then presented to the Queen by Major General Alastair Bruce of Crionaich, governor of Edinburgh Castle, who was assisted by three service cadets at the palace’s Equerry’s Door.
The Major General addressed the Queen, saying: “We, the serving members of Your Majesty’s Armed Forces, bound by our oath to You, your Heirs and Successors, offer for Your gracious acceptance the Key to Your Majesty’s Royal Castle of Edinburgh.”
To which she responded: “I return this key to the safekeeping of My Governor of Edinburgh Castle, in gratitude for the symbolic Act of Loyalty of Our Armed Forces, confident of your faithful allegiance to your oath.”
Three cheers for the Queen were then given by members of the armed forces before a pipe tune composed for the Platinum Jubilee called Dieu Ragnari was played as she waved goodbye and returned to the palace.
The act of loyalty and presentation of the key to Edinburgh Castle marked the 200th anniversary of King George IV’s visit to Scotland in 1822.
Later on Tuesday, the Princess Royal will then present honours in an investiture ceremony at the palace.
Among those to be recognised will be James McGoldrick, the assistant general secretary of the United Nations, and Ross McEwan, the chief executive of the Royal Bank of Scotland.