Scottish literature in the Middle Ages is literature written in Scotland, or by Scottish writers, between the departure of the Romans from Britain in the fifth century, until the establishment of the Renaissance in the late fifteenth century and early sixteenth century. It includes literature written in Brythonic, Scottish Gaelic, Scots, French and Latin.

Much of the earliest Welsh literature was composed in or near the country now called Scotland, in the Brythonic speech, from which Welsh would be derived. This includes the epic poem The Gododdin, considered the earliest surviving verse from Scotland. Very few works of Gaelic poetry survive from the early medieval period, and most of these are extant in Irish manuscripts. There are religious works that can be identified as Scottish. In Old English there is the Dream of the Rood, from which lines are found on the Ruthwell Cross, making it the only surviving fragment of Northumbrian Old English from early Medieval Scotland. What is probably the most important work written in early Medieval Scotland, the Vita Columbae by Adomnán, was also written in Latin.

As the state of Alba developed into the Kingdom of Scotland from the eighth century, a flourishing literary elite there regularly produced texts in both Gaelic and Latin, sharing a common literary culture with Ireland and elsewhere. It is possible that much Middle Irish literature was written in Medieval Scotland, but has not survived because the Gaelic literary establishment of eastern Scotland died out before the fourteenth century. After the Davidian Revolution of the thirteenth century, a flourishing French language culture predominated, while Norse literature was produced from areas of Scandinavian settlement.

In the late Middle Ages, Middle Scots became the dominant language of the country. The first surviving major text in Scots literature is John Barbour's Brus (1375). This was followed by major historical works in Latin, including the Chronica Gentis Scotorum of John of Fordun. There were also Scots versions of popular French romances. Much Middle Scots literature was produced by makars, poets with links to the royal court. Many of the makars had a university education and so were also connected with the Church. Much of their work survives in a single collection: the Bannatyne Manuscript, collated around 1560. In the late fifteenth century, Scots prose also began to develop as a genre. The first complete surviving work is John Ireland's The Meroure of Wyssdome (1490). The landmark work in the reign of James IV was Gavin Douglas's version of Virgil's Aeneid, the Eneados, which was the first complete translation of a major classical text in an Anglic language, finished in 1513, but overshadowed by the disaster at Flodden in the same year.

Early Middle Ages

After the collapse of Roman authority in the early fifth century, four major circles of political and cultural influence emerged in Northern Britain. In the East were the Picts, whose kingdoms eventually stretched from the River Forth to Shetland. Modern scholarship, based on surviving place names and historical evidence, indicates that the Pictish language was Brythonic (British).J. T. Koch, Celtic Culture: a Historical Encyclopedia (ABC-CLIO, 2006), , p. 305. In the West were the Gaelic (Goidelic-speaking) people of Dál Riata, who had close links with Ireland, from where they brought with them the name Scots. In the south were the British (Brythonic-speaking) descendants of the peoples of the Roman-influenced kingdoms of "The Old North", the most powerful and longest surviving of which was the Kingdom of Strathclyde. Finally, there were the English or "Angles", Germanic invaders who had overrun much of southern Britain and held the Kingdom of Bernicia (later the northern part of Northumbria), which reached into what are now the Borders of Scotland in the south-east.J. R. Maddicott and D. M. Palliser, eds, The Medieval State: essays presented to James Campbell (London: Continuum, 2000), , p. 48. To these languages Christianisation, particularly from the sixth century, added Latin as an intellectual and written language. No written literature for the Picts has survived into the modern era. However, there is surviving literature from what would become Scotland in Brythonic, Gaelic, Old English and Latin.

Much of the earliest Welsh literature was composed in or near the country now called Scotland, in the Brythonic speech, from which Welsh would be derived. At this time it was not then confined to Wales and Cornwall. These works were only written down in Wales much later. These include The Gododdin, considered the earliest surviving verse from Scotland, which is attributed to the bard Aneirin, said to have been resident in the Bythonic kingdom of Gododdin in the sixth century. It is a series of elegies to the men of Gododdin killed fighting at the Battle of Catraeth around 600 AD. Similarly, the Battle of Gwen Ystrad is attributed to Taliesin, traditionally thought to be a bard at the court of Rheged in roughly the same period.R. T. Lambdin and L. C. Lambdin, Encyclopedia of Medieval Literature (London: Greenwood, 2000), , p. 508.

Very few works of Gaelic poetry survive from the early medieval period, and most of these are in Irish manuscripts.Koch, Celtic Culture, p. 1576. There are religious works that can be identified as Scottish, including the Elegy for St Columba by Dallan Forgaill (c. 597) and "In Praise of St Columba" by Beccan mac Luigdech of Rum, c. 677.Koch, Celtic Culture, p. 999. A series of anecdotes contained in the tenth century Betba Adamnáin (Life of St. Adomnán) are probably derived from works composed on Iona. Outside of these there are a few poems in praise of Pictish kings contained within Irish annals that are probably from Scotland.

In Old English there is the Dream of the Rood, from which lines are found on the Ruthwell Cross, making it the only surviving fragment of Northumbrian Old English from early Medieval Scotland.E. M. Treharne, Old and Middle English c.890-c.1400: an Anthology (Wiley-Blackwell, 2004), , p. 108. It has also been suggested based on ornithological references that the poem The Seafarer was composed somewhere near the Bass Rock in East Lothian.T. O. Clancy, "Scottish literature before Scottish literature", in G. Carruthers and L. McIlvanney, eds, The Cambridge Companion to Scottish Literature (Cambridge Cambridge University Press, 2012), , p. 16.

Early works in Latin include a "Prayer for Protection" attributed to St Mugint, thought to be from the mid-sixth century, and Altus Prosator ("The High Creator"), attributed to St Columba (c. 597).I. Brown, T. Owen Clancy, M. Pittock, S. Manning, eds, The Edinburgh History of Scottish Literature: From Columba to the Union, until 1707 (Edinburgh: Edinburgh University Press, 2007), , p. 94. What is probably the most important work written in early Medieval Scotland, the Vita Columbae, by Adomnán, abbot of Iona (627/8–704), was also written in Latin.C. Gross, The Sources and Literature of English History from the Earliest Times to about 1485 (Elibron Classics Series, 1999), , p. 217. The next most important piece of Scottish hagiography, the verse Life of St. Ninian, was written in Latin in Whithorn, perhaps as early as the eighth century.Clancy, "Scottish literature before Scottish literature", p. 19.

High Middle Ages

Beginning in the later eighth century, Viking raids and invasions may have forced a merger of the Gaelic and Pictish crowns. The Kingdom of Alba emerged, which would eventually become known as the Kingdom of Scotland, and traced its origin to Cínaed mac Ailpín (Kenneth MacAlpin) in the 840s through the House of Alpin.B. Yorke, The Conversion of Britain: Religion, Politics and Society in Britain c.600–800 (Pearson Education, 2006), , p. 54. The Kingdom of Alba was overwhelmingly an oral society dominated by Gaelic culture. Fuller sources for Ireland of the same period suggest that there would have been filidh, who acted as poets, musicians and historians, often attached to the court of a lord or king, and passed on their knowledge and culture in Gaelic to the next generation.R. A. Houston, Scottish Literacy and the Scottish Identity: Illiteracy and Society in Scotland and Northern England, 1600–1800 (Cambridge: Cambridge University Press, 2002), , p. 76. Historical sources, as well as place name evidence, indicate how the Pictish language in the north and Cumbric languages in the south were overlaid and replaced by Gaelic, Old English and later Norse.W. O. Frazer and A. Tyrrell, Social Identity in Early Medieval Britain (London: Continuum, 2000), , p. 238.

From the eleventh century French, Flemish and particularly English became the main languages of Scottish burghs, most of which were located in the south and east.K. J. Stringer, "Reform Monasticism and Celtic Scotland", in E. J. Cowan and R. A. McDonald, eds, Alba: Celtic Scotland in the Middle Ages (East Lothian: Tuckwell Press, 2000), , p. 133. At least from the accession of David I (r. 1124–53), as part of a Davidian Revolution that introduced French culture and political systems, Gaelic ceased to be the main language of the royal court and was probably replaced by French. After this "de-gallicisation" of the Scottish court, a less highly regarded order of bards took over the functions of the filidh, and they would continue to act in a similar role in the Highlands and Islands into the eighteenth century. They often trained in bardic schools. A few of these, like the one run by the MacMhuirich dynasty, who were bards to the Lord of the Isles,K. M. Brown, Noble Society in Scotland: Wealth, Family and Culture from the Reformation to the Revolutions (Edinburgh: Edinburgh University Press, 2004), , p. 220. continued until they were suppressed from the seventeenth century. Members of bardic schools were trained in the complex rules and forms of Gaelic poetry. Much of their work was never written down, and what survives was only recorded from the sixteenth century.R. Crawford, Scotland's Books: A History of Scottish Literature (Oxford: Oxford University Press, 2009), .

It is possible that more Middle Irish literature was written in Medieval Scotland than is often thought, but has not survived because the Gaelic literary establishment of eastern Scotland died out before the fourteenth century. Although surviving only from manuscripts preserved in Ireland, Thomas Owen Clancy has argued that the Lebor Bretnach, the so-called "Irish Nennius", was written in Scotland, and probably at the monastery in Abernethy.T. O. Clancy, "Scotland, the 'Nennian' recension of the Historia Brittonum, and the Lebor Bretnach", in S. Taylor, ed., Kings, Clerics and Chronicles in Scotland, 500–1297 (Dublin/Portland, 2000), , pp. 87–107. Other literary works that have survived include that of the prolific poet Gille Brighde Albanach. His Heading for Damietta (c. 1218) dealt with his experiences of the Fifth Crusade.T. O. Clancy and G. Márkus, The Triumph Tree: Scotland's Earliest Poetry, 550–1350 (Canongate Books, 1998), , pp. 247–283.

The twelfth century, a period that saw the arrival of new religious orders and changes in the structure of the church, was the high point of Scottish hagiography. There was a proliferation of Latin lives of the saints, often venerating early Celtic and Scottish figures, and the creation or embellishment of foundations myths for religious centres including St. Andrews, Glasgow and Dunkeld. Many earlier saints' lives are preserved in the Aberdeen Breviary (1509–10), compiled for William Elphinstone, Archbishop of Aberdeen.