Scotland in the Late Middle Ages, between the deaths of Alexander III in 1286 and James IV in 1513, established its independence from England under figures including William Wallace in the late 13th century and Robert Bruce in the 14th century. In the 15th century under the Stewart Dynasty, despite a turbulent political history, the Crown gained greater political control at the expense of independent lords and regained most of its lost territory to approximately the modern borders of the country. However, the Auld Alliance with France led to the heavy defeat of a Scottish army at the Battle of Flodden in 1513 and the death of the king James IV, which would be followed by a long minority and a period of political instability.
The economy of Scotland developed slowly in this period and a population of perhaps a little under a million by the middle of the 14th century began to decline after the arrival of the Black Death, falling to perhaps half a million by the beginning of the 16th century. Different social systems and cultures developed in the lowland and highland regions of the country as Gaelic remained the most common language north of the Tay and Middle Scots dominated in the south, where it became the language of the ruling elite, government and a new national literature. There were significant changes in religion which saw mendicant friars and new devotions expand, particularly in the developing burghs.
By the end of the period Scotland had adopted many of the major tenets of the European Renaissance in art, architecture and literature and produced a developed educational system. This period has been seen one in which a clear national identity emerged in Scotland, as well as significant distinctions between different regions of the country which would be particularly significant in the period of the Reformation.