The Queen has attended an Armed Forces act of loyalty parade at her official Scottish residence.
Members of all three services took part in the service at the Palace of Holyroodhouse in Edinburgh to celebrate her visit to Scotland and mark her Platinum Jubilee there.
The parade centred on the presentation of the key for Edinburgh Castle as part of the Royal visit tradition.
A parade and presentation of the key for Edinburgh Castle also took place in the gardens of the palace.
Members of all three services marched to Her Majesty's official Scottish residence in Edinburgh for the act of loyalty parade, also paying tribute to the Queen in her role as head of the UK's Armed Forces.
The Queen arrived in the city yesterday ahead of a series of official Royal engagements being carried out by both the Duke of Rothesay and the Princess Royal.
The Queen was welcomed with the Royal Salute before chatting with members of all three branches of the military during the service.
She was then presented with the key to the castle as part of the ceremony 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.
As is tradition, the key is immediately returned to the Governor to show the faith the monarch has in the city's authority to govern on her behalf.
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.
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."
The Queen 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.
Public appearances like this are becoming increasingly rare, but the Queen did not miss the chance to pay tribute to the Armed Forces who serve her in Scotland.
Tuesday's ceremony in Edinburgh comes a few weeks after nationwide celebrations for the Queen's landmark Platinum Jubilee – 70 years since she ascended to the throne – in which the Armed Forces played a key role.