While the area around modern-day Edinburgh has been inhabited for thousands of years,G and A Ritchie, Scotland, Archaeology and early history, Thames & Hudson 1981, reports Bronze Age finds at Magdalen Bridge, Duddingston Loch, Moredun, Granton and Mortonhall the history of Edinburgh as a definite settlement can be traced to the early Middle Ages when a hillfort was established in the area, most likely on the Castle Rock. From the seventh to the tenth centuries it was part of the Anglian Kingdom of Northumbria, becoming thereafter a royal residence of the Scottish kings. The town that developed next to the stronghold was established by royal charter in the early 12th century, and by the middle of the 14th century was being described as the capital of Scotland. The area known as the New Town was added from the second half of the 18th century onwards. Edinburgh was Scotland's largest city until Glasgow outgrew it in the first two decades of the 19th century. Following Scottish devolution in the very late 20th century, Scotland's Parliament was re-established in Edinburgh.

Origins

The earliest known human habitation in the Edinburgh area is from Cramond where evidence has been found of a Mesolithic site dated to c.8500 BC. Traces of later Bronze Age and Iron Age settlements have been found on the Castle Rock, Arthur's Seat, Craiglockhart Hill and the Pentland Hills. The culture of these early inhabitants bears similarities with the Celtic cultures of the Iron Age found at Hallstatt and La Tène in central Europe. When the Romans arrived in the Lothian area towards the end of the 1st century AD, they discovered a Celtic Brythonic tribe whose name they recorded as the Votadini.G & A Ritchie, Edinburgh and South-East Scotland, Regional Archaeologlogies Series, Heinemann 1972, p.51 The Romans established a fort at Cramond, within what later grew to be Edinburgh. Traditional scholarship situated Cramond in the northerly Roman province of Valentia although this is now disputed. Certainly, it was connected to York with the Roman Road known as Dere Street.

At some point before the 7th century AD, the Gododdin, presumed descendants of the Votadini, built a hillfort known as Din Eidyn in the area of Eidyn, modern Edinburgh. Although the exact location of the hillfort has not been identified, it seems more than likely they would have chosen the commanding position of the Castle Rock, or Arthur's Seat or the Calton Hill. During the time of the Gododdin, the territory of Lothian came to be recognized, with Edinburgh as its main stronghold. Around the year 600, Welsh tradition records that Mynyddog Mwynfawr, the Brythonic ruler of the kingdom of Gododdin, assembled a force within the vicinity of Edinburgh to oppose Germanic settlers to the south. This force was decisively defeated by the Angles at the Battle of Catraeth (probably at Catterick).

Northumbrian Edinburgh (7th to 10th centuries)

The Angles of the Kingdom of Bernicia had a significant influence on what would be successively Bernicia, Northumbria and finally south-east Scotland, notably from AD 638 when it appears that the Gododdin stronghold was besieged by forces loyal to King Oswald of Northumbria. Whether or not this battle marked the precise passing of control over the hillfort of Etin from the Brythonic Celts to the Northumbrians, it was around this time that the Edinburgh region came under Northumbrian rule. In the following years the Angles extended their influence west and north of Edinburgh but following their defeat at the Battle of Nechtansmere in AD 685 Edinburgh may have come to mark the north west extremity of the Angles' kingdom. According to the Anglo-Saxon Chronicle, in 710 the Angles fought against the Picts between the rivers Avon and Carron which flow into the River Forth from the south about 20 miles west of Edinburgh.þam ylcan geare feaht Beorhtfrið ealdorman wið Pehtas betwux Hæfe & Cære Though not exclusive, Anglian influence predominated from the mid-seventh century to the mid-tenth century, with Edinburgh as a frontier stronghold. During this period Edinburgh became a place where Northumbrian Old English was spoken and its name acquired the Old English suffix, "-burh".

While history records little about Northumbrian Edinburgh, the English chronicler Symeon of Durham, writing in c. 1130 and copying from earlier texts, mentioned a church at Edwinesburch in AD 854 which came under the authority of the Bishop of Lindisfarne. It has been inferred from this report that there was therefore an established settlement by the middle of the ninth century. It is possible that this church was a forerunner of what was later to become St Giles' Cathedral or St Cuthbert's Church. Traditionally and less certainly, Saint Cuthbert is said to have preached the gospel around the Castle Rock in the second half of the seventh century.

The development of a fortress on the Castle Rock is shrouded in uncertainty. It has been suggested that a stronghold was established by the Northumbrians in the seventh century, but the archaeological and historical evidence is scant, except for indications that by the end of Edinburgh's Northumbrian period (the middle of the 10th century) there was some form of noble residence on the site.

In the late ninth century the Danelaw, centred on York, was established in the wake of Viking raids on Britain. The northern part of Northumbria was cut off from the rest of England by the Old Norse-speaking Danes, significantly weakening what remained of the kingdom. However, in 927 the English king, Athelstan, defeated the Danes and received the submission of the Anglo-Saxon Northumbrians. Seven years later, in 934, the Annals of Clonmacnoise record that Æthelstan, who spent much time stamping his authority upon the north, ravaged Scotland to Edinburgh but that he was forced to depart without any great victory. As Edinburgh was not part of Scotland at that time, the wording of the Chronicle in this regard has been described as "odd" and "difficult to understand." One explanation is that "to" or "as far as" Edinburgh should be read as "from", implying that Æthelstan assembled his forces at Edinburgh at the outset of his campaign.

During the tenth century the northernmost part of Northumbria, which had retained its Brythonic name Lothian, came under the sway of the Kingdom of Scotland. The 11th century Chronicle of the Kings of Alba records that "oppidum Eden", usually identified as Edinburgh,Duncan, p. 24; Early Sources, p.468, note 4. "was evacuated, and abandoned to the Scots until the present day." This has been read as indicating that Lothian was ceded to the Scottish king Indulf who reigned from AD 954 to 962. Thereafter Edinburgh generally remained under the jurisdiction of the Scots.

Medieval burgh (11th century to 1560)

In AD 973 during a royal council at Chester, the English king Edgar the Peaceful formally granted Lothian to Kenneth II, King of Scots. The historian Marjorie Anderson holds that this was the key event in assuring Scottish rule over Lothian. By the early 11th century the Scottish hold over the area was secured when Malcolm II ended the Northumbrian threat by his victory at the battle of Carham in 1018.J and J Keay (ed.), Collins Encyclopaedia of Scotland, (1994), p.137 While Malcolm Canmore (r.1058–1093) kept his court and residence at Dunfermline, north of the Forth, he began spending more time at Edinburgh where he built a chapel for his wife Margaret to carry out her devotions. St. Margaret's Chapel within Edinburgh Castle has been traditionally regarded as Edinburgh's oldest extant building, though most scholars now believe that in its surviving form it was more likely built by Margaret's youngest son David I in his mother's memory.D Daiches, Edinburgh (1978) pp.13–14

In the wake of the Norman Harrying of the North (1069–70), refugees fled from northern England to lowland Scotland, including Edinburgh.

In the 12th century (c.1130), King David I, established the town of Edinburgh as one of Scotland's earliest royal burghs, protected by his royal fortress, on the slope below the castle rock. Merchants were allocated strips of land known as "tofts", ranged along both sides of a long market street, on condition that they built a house on their land within a year and a day. Each toft stretched back from the street to a perimeter dyke and formed a private close (from Old French clos), meaning an enclosed yard. A separate, contiguous burgh of regality held by the Abbey of Holyrood developed to the east as the burgh of Canongate.

Edinburgh was largely in English hands from 1291 to 1314 and from 1333 to 1341, during the Wars of Scottish Independence. The English nobleman, Lord Basset was made Governor of Edinburgh Castle in 1291. When the English invaded Scotland in 1298, King Edward I chose not to enter the English controlled town of Edinburgh but passed by with his army.

In 1334, Edward Balliol, the English-backed claimant to the Scottish throne, granted Edward III of England large portions of southern Scotland, including Edinburgh as part of the Treaty of Newcastle. After the loss of Scotland's main trading port Berwick to English occupation in the 1330s, the bulk of the kingdom's profitable export trade in skins, hides, and most notably wool was routed through Edinburgh and its port of Leith.M Lynch, Scotland, A New History (2000), p. 173 During Edward III's ill-fated Burnt Candlemas, invasion of Scotland, Edward and his army arrived at Edinburgh in early February and had much of the town burnt. By the middle of the 14th century, in the reign of David II, the French chronicler Froissart described the town of around 400 dwellings as "the Paris of Scotland" (c.1365 ). The Scottish king James II (1430–60) was "born, crowned, married and buried in the Abbey of Holyrood", and James III (1451–88) described Edinburgh in one of his charters as "the principal burgh of our kingdom" (principalior burgus regni nostri). By the reign of James V (1512–42) Edinburgh's assessment for taxation sometimes equalled the combined figures for the next three burghs in the kingdom; its proportion of total burgh taxation amounting to a fifth or a quarter and its total customs to a half or more. Despite wholesale destruction reported by contemporaries at the time of the Hertford Raid in 1544, the town slowly recovered with its population of merchant burgesses and craftsmen continuing to serve the needs of the royal court and nobility. Incorporated trades were cordiners (shoemakers), hatmakers, websters (weavers), hammermen (smiths and lorimers, i.e. leather workers), skinners, fleshers (butchers), coopers, wrights, masons, waulkers (fullers), tailors, barber-surgeons, baxters (bakers), and candlemakers.J B Barclay, Edinburgh (Adam and Charles Black, London 1965) With the rise of taxes imposed by the burgh, some of these crafts relocated to suburbs beyond the town's boundary in the sixteenth and seventeenth centuries.Aaron M. Allen, "Conquering the Suburbs: Politics and Work in Early Modern Edinburgh," Journal of Urban History (2011) 37#3 pp 423–443

In 1560, at a time when Scotland's total population was an estimated one million people, Edinburgh's population reached 12,000, with another 4,000 in separate jurisdictions such as Canongate and the port of Leith. A parish census in 1592 recorded 8003 adults spread evenly south and north of the High Street; 45 per cent of the employed being domestic servants in the households of the legal and merchant professions or in town houses of the landed classP G B McNeill and H L MacQueen (eds.), Atlas of Scottish History to 1707(University of Edinburgh 1996), pp.456–7 gives the number of households as 2,239. Despite periodic outbreaks of plague with high death rates, most notably in 1568, 1584–88 and 1645, the population continued to grow steadily.

Reformation era