Gunners from 105th Regiment Royal Artillery (Volunteers) fired the two 21-gun royal salutes at noon yesterday.
Meanwhile, 1st Battalion Scots Guards, in their familiar red tunics and bearskins, provided both castle guards.
It is the first time the battalion has mounted a guard at Stirling in more than 300 years.
The royal salutes took place as the Queen attended the Trooping the Colour parade at Horse Guards Parade in London’s Whitehall.
Commanding officer of the 105th Regiment, Lieutenant Colonel James Cook, said: “As the Scottish and Ulster Gunners, we are honoured to be firing royal salutes at Edinburgh and Stirling Castles on the occasion of Her Majesty the Queen’s official birthday.
“We are extremely privileged to have the general officer commanding Scotland, Major General Nick Eeles, as the reviewing officer at Stirling Castle; and the deputy commander land forces, Major General Ranald Munro, as the reviewing officer at Edinburgh Castle.
“In addition, the regiment has now been given the official authority to fire four royal salutes annually at Stirling Castle. These will usually be fired by the regiment’s 212 (Highland) Battery.”
Music at Stirling Castle was provided by the Highland Band of the Royal Regiment of Scotland. The royal salute at Edinburgh Castle was fired by 207 Battery, with music from the Lowland Band of The Royal Regiment of Scotland.
Meanwhile, in London the Duchess of Cambridge made her last public appearance before the birth of her first child when she joined thousands of well-wishers to celebrate the Queen’s official birthday.
The duchess who is eight months pregnant, watched as the Duke of Cambridge took part in the parade on horseback as Colonel of the Irish Guards. The Queen also looked cheerful as she watched the military spectacle, despite the Duke of Edinburgh being unable to attend due to ill health.