Edinburgh Castle has played a pivotal role in Scottish history, both as a royal residence – King Malcolm Canmore (r 1058–93) and Queen Margaret first made their home here in the 11th century – and as a military stronghold. The castle last saw military action in 1745; from then until the 1920s it served as the British army's main base in Scotland. Today it is one of Scotland's most atmospheric and most popular tourist attractions.
The brooding, black crags of Castle Rock, rising above the western end of Princes St, are the very reason for Edinburgh's existence. This rocky hill was the most easily defended hilltop on the invasion route between England and central Scotland, a route followed by countless armies from the Roman legions of the 1st and 2nd centuries AD to the Jacobite troops of Bonnie Prince Charlie in 1745.
The Entrance Gateway , flanked by statues of Robert the Bruce and William Wallace, opens to a cobbled lane that leads up beneath the 16th-century Portcullis Gate to the cannons ranged along the Argyle and Mills Mount batteries. The battlements here have great views over New Town to the Firth of Forth.
At the far end of Mills Mount Battery is the famous One O'Clock Gun , where crowds gather to watch a gleaming WWII 25-pounder fire an ear-splitting time signal at exactly 1pm (every day except Sunday, Christmas Day and Good Friday).
South of Mills Mount, the road curls up leftwards through Foog's Gate to the highest part of Castle Rock, crowned by the tiny, Romanesque St Margaret's Chapel , the oldest surviving building in Edinburgh. It was probably built by David I or Alexander I in memory of their mother, Queen Margaret, sometime around 1130 (she was canonised in 1250). Beside the chapel stands Mons Meg , a giant 15th-century siege gun built at Mons (in what is now Belgium) in 1449.
The main group of buildings on the summit of Castle Rock is ranged around Crown Sq, dominated by the shrine of the Scottish National War Memorial . Opposite is the Great Hall, built for James IV (r 1488–1513) as a ceremonial hall and used as a meeting place for the Scottish parliament until 1639. Its most remarkable feature is the original, 16th-century hammer-beam roof.
The Castle Vaults beneath the Great Hall (entered from Crown Sq via the Prisons of War exhibit) were used variously as storerooms, bakeries and a prison. The vaults have been renovated to resemble 18th- and early 19th-century prisons, where graffiti carved by French and American prisoners can be seen on the ancient wooden doors.
On the eastern side of the square is the Royal Palace , built during the 15th and 16th centuries, where a series of historical tableaux leads to the highlight of the castle – a strongroom housing the Honours of Scotland (the Scottish crown jewels), the oldest surviving crown jewels in Europe. Locked away in a chest following the Act of Union in 1707, the crown (made in 1540 from the gold of Robert the Bruce's 14th-century coronet), sword and sceptre lay forgotten until they were unearthed at the instigation of the novelist Sir Walter Scott in 1818. Also on display here is the Stone of Destiny .
Among the neighbouring Royal Apartments is the bedchamber where Mary, Queen of Scots gave birth to her son James VI, who was to unite the crowns of Scotland and England in 1603.