The salute is part of a series of events marking the days around her Diamond Jubilee.
Tourists at the castle, on top of the Royal Mile, gathered to watch the ceremony which followed entertainment from a military brass band.
The salute was made by the 105th Regiment Royal Artillery (Volunteers).
Lieutenant Colonel James Cook said: “The regiment is honoured to be firing a 21-gun royal salute today, as the nation celebrates Her Majesty’s Diamond Jubilee.
“The royal salute provides a great occasion for the gunners to display their professionalism and pride in conducting such an honour in Scotland’s capital city.”
The ceremony was watched by reviewing officer Allan Moffat, assistant chief constable of Central Scotland Police.
At the other end of the historic thoroughfare, preparations were under way for jubilee events at the Palace of Holyroodhouse, the Queen’s official residence in Scotland.
A big screen will show the pageant on the River Thames in London and families are being encouraged to bring a picnic. The palace will stay open into the night on Monday when a beacon will be lit on the roof.
Opposite the palace at the Scottish Parliament, an oak tree was planted by the Woodland Trust on Wednesday. MSPs marked the Queen’s reign with speeches inside the debating chamber.
Meanwhile, First Minister Alex Salmond has hailed the launch of a free “Queen of Scots” phone app which offers video footage and rare images of some of her visits to Scotland.
Mr Salmond said: “The Queen has given Scotland 60 years of unparalleled service, and the Jubilee weekend will offer the people of Scotland a fantastic opportunity to celebrate that service and reflect on Her Majesty’s reign.
“During her time on the throne the Queen has been a particular friend to Scotland, and her many memorable visits have offered a wealth of fabulous memories for Scots of all ages.
“Our Queen of Scots app captures that excitement, offering exclusive images of Her Majesty’s official visits to places in Scotland such as Iona, Melrose and Shetland as well as video and pictures of high-profile events such as the reopening of the Scottish Parliament in 1999 and the visit of the Pope in 2010.
“The app is an exciting mix of the traditional and modern and gives people an innovative way of learning about Her Majesty’s reign in this country. I hope it helps people in today’s modern, digital Scotland celebrate the jubilee and commemorate the wonderful service offered to them by their Queen.”
The Royal Yacht Britannia, moored at the port of Leith, is hosting a weekend of celebrations which includes entertainment, cake and flags being given out.
Britannia’s royal barge will act as an escort boat in the pageant on the Thames. It was waved off during a ceremony this week.
About one-third of all Scotland’s street party applications were made in the capital, which could see about 30 road closures.