| Edinburgh Castle is an ancient stronghold which dominates the sky-line of the city of Edinburgh from its position atop the volcanic Castle Rock. Human habitation of the site is dated back as far as the 9th century BC, although the nature of early settlement is unclear. There has been a royal Castle here since at least the reign of David I in the 12th century, and the site continued to be a royal residence until the Union of the Crowns in 1603. As one of the most important fortresses in the Kingdom of Scotland, Edinburgh Castle has been involved in many historical conflicts, from the Wars of Scottish Independence in the 14th century, up to the Jacobite Rising of 1745, and has been besieged, both successfully and unsuccessfully, on several occasions. From the later 17th century, the Castle became a military base, with a large garrison. Its importance as a historic monument was recognised from the 19th century, and various restoration programmes have been carried out since.|
Few of the present buildings pre-date the Lang Siege of the 16th century, when the fortifications were largely destroyed by artillery bombardment. The notable exception is St Margaret's Chapel, the oldest surviving building in Edinburgh, which dates from the early 12th century. Among other significant buildings of the Castle are the Royal Palace, and the 15th-century Great Hall. The Castle also houses the Scottish National War Memorial, and National War Museum of Scotland.
The Castle is now in the care of Historic Scotland, and is Scotland's second-most-visited tourist attraction. Although the garrison left in the 1920s, there is still a military presence at the Castle, largely ceremonial and administrative, and including a number of regimental museums. It is also the backdrop to the annual Edinburgh Military Tattoo, and has become a recognisable symbol of Edinburgh and of Scotland.