The Kingdom of Scotland (c. 843-1707) grew from the union of the Picts and the Scots of Dal Riata under Kenneth MacAlpin, traditionally dated to 843. The early kingdom, Alba, was Gaelic-speaking and centered east of the Highlands. Through war and marriage it absorbed the British kingdom of Strathclyde and, after the battle of Carham (1018), English-speaking Lothian, reaching roughly its modern borders. Under Malcolm III and his English queen Margaret, an Anglo-Saxon princess later canonized, and their sons, especially David I (1124-1153), the kingdom was transformed along Norman lines: feudal lordships and castles, royal burghs, reformed coinage and new monasteries such as Melrose and Holyrood.
Relations with England defined the kingdom's history. Scottish kings held lands in England and paid homage for them, but fiercely guarded their independence. When the direct line failed in 1290, Edward I of England arbitrated the succession, chose John Balliol, and then treated Scotland as a vassal. Resistance erupted under William Wallace, victor at Stirling Bridge (1297), defeated at Falkirk (1298) and executed in 1305. Robert the Bruce, after killing his rival John Comyn, seized the throne in 1306 and won independence the hard way, destroying Edward II's army at Bannockburn in 1314. The Declaration of Arbroath (1320) declared to the pope that Scots fought 'not for glory, riches or honours, but for freedom alone', and England recognized the kingdom in 1328.
Under the Stewart dynasty, from Robert II in 1371, Scotland remained a small, poor but stubborn kingdom. Its 'Auld Alliance' with France, from 1295, countered English pressure, and border warfare was endemic; the death of James IV at Flodden (1513) was the worst disaster of the age. Scottish kings struggled to master their own magnates, and several died violently. The 16th century brought the Reformation: in 1560 the Scottish Parliament, led by John Knox and the Lords of the Congregation, established a Protestant kirk, and the Catholic Mary Queen of Scots, driven from her throne, was eventually executed by Elizabeth I of England in 1587.
In 1603 James VI of Scotland inherited the English throne as James I, uniting the crowns while the kingdoms remained legally separate. The century that followed brought civil wars, Covenanter resistance to royal religious policy, and the ruinous Darien colonial scheme (1698-1700). Pressured by economic need and English politics, the Scottish Parliament voted the Acts of Union of 1707, merging Scotland with England into Great Britain and dissolving the old kingdom. Scotland kept its own church, law and education, foundations of a distinct national life that survived the loss of statehood.