<P> The death of king Alexander III in 1286, and the death of his granddaughter and heir Margaret, Maid of Norway in 1290, left 14 rivals for succession . To prevent civil war the Scottish magnates asked Edward I of England to arbitrate, for which he extracted legal recognition that the realm of Scotland was held as a feudal dependency to the throne of England before choosing John Balliol, the man with the strongest claim, who became king in 1292 . Robert Bruce, 5th Lord of Annandale, the next strongest claimant, accepted this outcome with reluctance . Over the next few years Edward I used the concessions he had gained to systematically undermine both the authority of King John and the independence of Scotland . In 1295 John, on the urgings of his chief councillors, entered into an alliance with France, known as the Auld Alliance . </P> <P> In 1296 Edward invaded Scotland, deposing King John . The following year William Wallace and Andrew de Moray raised forces to resist the occupation and under their joint leadership an English army was defeated at the Battle of Stirling Bridge . For a short time Wallace ruled Scotland in the name of John Balliol as Guardian of the realm . Edward came north in person and defeated Wallace at the Battle of Falkirk (1298). Wallace escaped but probably resigned as Guardian of Scotland . In 1305 he fell into the hands of the English, who executed him for treason despite the fact that he owed no allegiance to England . </P> <P> Rivals John Comyn and Robert the Bruce, grandson of the claimant, were appointed as joint guardians in his place . On 10 February 1306, Bruce participated in the murder of Comyn, at Greyfriars Kirk in Dumfries . Less than seven weeks later, on 25 March, Bruce was crowned as King . However, Edward's forces overran the country after defeating Bruce's small army at the Battle of Methven . Despite the excommunication of Bruce and his followers by Pope Clement V, his support slowly strengthened; and by 1314 with the help of leading nobles such as Sir James Douglas and Thomas Randolph only the castles at Bothwell and Stirling remained under English control . Edward I had died in 1307 . His heir Edward II moved an army north to break the siege of Stirling Castle and reassert control . Robert defeated that army at the Battle of Bannockburn in 1314, securing de facto independence . In 1320 the Declaration of Arbroath, a remonstrance to the Pope from the nobles of Scotland, helped convince Pope John XXII to overturn the earlier excommunication and nullify the various acts of submission by Scottish kings to English ones so that Scotland's sovereignty could be recognised by the major European dynasties . The Declaration has also been seen as one of the most important documents in the development of a Scottish national identity . </P> <P> In 1326, what may have been the first full Parliament of Scotland met . The parliament had evolved from an earlier council of nobility and clergy, the colloquium, constituted around 1235, but perhaps in 1326 representatives of the burghs--the burgh commissioners--joined them to form the Three Estates . In 1328, Edward III signed the Treaty of Edinburgh--Northampton acknowledging Scottish independence under the rule of Robert the Bruce . However, four years after Robert's death in 1329, England once more invaded on the pretext of restoring Edward Balliol, son of John Balliol, to the Scottish throne, thus starting the Second War of Independence . Despite victories at Dupplin Moor and Halidon Hill, in the face of tough Scottish resistance led by Sir Andrew Murray, the son of Wallace's comrade in arms, successive attempts to secure Balliol on the throne failed . Edward III lost interest in the fate of his protégé after the outbreak of the Hundred Years' War with France . In 1341 David II, King Robert's son and heir, was able to return from temporary exile in France . Balliol finally resigned his claim to the throne to Edward in 1356, before retiring to Yorkshire, where he died in 1364 . </P>

When did scotland gain its independence from england