Education in Medieval Scotland includes all forms of education within the modern borders of Scotland, between the departure of the Romans from Britain in the fifth century, until the establishment of the Renaissance late fifteenth century and early sixteenth century. Few sources on Scottish education survived the Medieval era. In the early Middle Ages, Scotland was an oral society, with verbal rather than literary education. Though there are indications of a Gaelic education system similar to that of Ireland, few details are known. The establishment of Christianity from the sixth century brought Latin to Scotland as a scholarly and written language. Monasteries served as major repositories of knowledge and education, often running schools.
 In the High Middle Ages, new sources of education arose, such as song and grammar schools designed to train priests with emphases on music and Latin grammar, respectively. The number and size of these schools expanded rapidly after the 1380s. By the end of the Middle Ages, all the main burghs and some small towns had grammar schools. Educational provision was probably much weaker in rural areas, but there were petty or reading schools in rural areas, providing an elementary education. There was also the development of private tuition in the families of lords and wealthy burghers that sometimes developed into "household schools". Girls of noble families were taught in nunneries and by the end of the fifteenth century Edinburgh also had schools for girls. There is documentary evidence for about 100 schools of these different kinds before the Reformation. The Education Act 1496 decreed that all sons of barons and freeholders of substance should attend grammar schools to learn "perfyct Latyne". All this resulted in an increase in literacy, with perhaps 60 per cent of the nobility being literate by the end of the period.
 Those who wished to attend university had to travel to England or the continent, and just over 1,000 students have been identified as doing so between the twelfth century and 1410. Major intellectual figures produced by Scotland with this system included John Duns Scotus, Walter Wardlaw, William de Tredbrum, Laurence de Lindores and John Mair. This situation was transformed by the founding of St John's College, St Andrews (1418). St Salvator's College was added to St. Andrews in 1450, followed by foundations at Glasgow in 1451 and King's College, Aberdeen in 1495. Initially, these institutions were designed for the training of clerics, but they would increasingly be used by laymen who began to challenge the clerical monopoly of administrative posts in government and law. They provided only basic degrees and those wanting to study for the more advanced degrees, which were common amongst European scholars, needed to go to universities in other countries. In this period, Scottish universities largely had a Latin curriculum, designed for the clergy and civil and canon lawyers. Towards the end of the fifteenth century, a humanist influence and the teaching of Greek was becoming more evident.
 Surviving sources for Medieval Scotland are much more limited than for contemporaneous England. The only burgh for which there are sources pre-dating 1400 is Aberdeen. The only large body of sources to survive from before 1400 are the cartularies of monasteries. For education, outside of occasional references in documents concerned with other matters, they amount to a handful of burgh records and monastic and episcopal registers.
 In the early Middle Ages, Scotland was overwhelmingly an oral society and education was verbal rather than literary. Fuller sources for Ireland of the same period suggest that there were filidh, who acted as poets, musicians and historians, often attached to the court of a lord or king, and who passed on their knowledge in Gaelic to the next generation. After the "de-gallicisation" of the Scottish court from the twelfth century, a less highly regarded order of bards took over these functions 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, of which a few, such as the one run by the MacMhuirich dynasty, who were bards to the Lord of the Isles, existed in Scotland and a larger number in Ireland, until they were suppressed from the seventeenth century. Much of their work was never written down and what survives was only recorded from the sixteenth century. Evidence of formal schooling is largely only preserved in place names.
 The establishment of Christianity from the sixth century brought Latin to Scotland as a scholarly and written language. Monasteries served as major repositories of knowledge and education, often running schools and providing a small, educated and overwhelmingly male, elite, who were essential to create and read documents in a largely illiterate society. Literary life revolved around the contemplation of texts and the copying of manuscripts. Libraries were of great importance to monastic communities. The one at Iona may have been exceptional, but it demonstrates that the monks were part of the mainstream of European Christian culture.
 In the High Middle Ages, new sources of education arose. Choir and grammar schools were designed to train priests, with an emphasis respectively on music and Latin grammar. The reorganisation of the church that began in the reign of David I (1124–53) gave the church a clearer diocesan and parochial structure, meaning that the seats of sheriffdoms, such as Perth, received schools that were usually under monastic patrons. Early examples of grammar schools include the High School of Glasgow in 1124 and the High School of Dundee in 1239. These were usually attached to cathedrals or a collegiate church. The newly created diocesan chancellors may have had authority over cathedral schools and schoolmasters within their diocese.
 The new religious orders that became a major feature of Scottish monastic life in this period also brought new educational possibilities and the need to train larger numbers of monks. Benedictine and Augustinian foundations probably had almonry schools, charity schools using funds from the almoner to provide a type of bursary to educate young boys, who might enter the priesthood. At the Cluniac Paisley Abbey, secular chaplains were employed as schoolmasters. Some monasteries, including the Cistercian abbey at Kinloss, Sweetheart Abbey and Beauly, opened their doors to a wider range of students to teach the sons of gentlemen. St Andrews, which was both the seat of a bishop and the site of a major Augustinian foundation, had both a grammar school, under the archdeacon, and a song school, under the priory. The foundation of over 100 collegiate churches of secular priests between 1450 and the Reformation would have necessitated the training of large numbers of choristers. Sometimes, as at Lochwinnoch, they were taught both music and grammar. Dominican friars were noted for their educational achievements and were usually located in urban centres, probably teaching grammar, as at Glasgow and Ayr. The number and size of these schools seems to have expanded rapidly from the 1380s. By the end of the Middle Ages, grammar schools could be found in all the main burghs and some small towns.
 Educational provision was probably much weaker in rural areas, but there were petty or reading schools that provided an elementary education. There was also the development of private tuition in the families of lords and wealthy burghers. Sometimes these developed into "household schools", that may also have catered to neighbours and kin, as well as the sons of the laird's household, which is known to have happened at Huntly. All these schools were almost exclusively aimed at boys. Girls of noble families were taught in nunneries such as Elcho, Aberdour and Haddington. By the end of the fifteenth century Edinburgh also had schools for girls, sometimes described as "sewing schools", whose name probably indicates one of their major functions. Although reading may also have been taught in these schools, the students were probably taught by lay women or nuns.
 There is documentary evidence for about 100 schools of these different kinds before the Reformation. Most of the schoolmasters of these schools were clergy, and also acted as chaplains of religious foundations, hospitals or private chaplains of noblemen to supplement their merge incomes. To some extent, all education was controlled by different branches of the church, but towards the end of the period there was an increasing lay interest. This sometimes resulted in conflict, as between the burgh of Aberdeen and the cathedral chancellor, when the former appointed a lay graduate as schoolmaster in 1538, and when a married man was appointed to the similar post in Perth. Education began to widen beyond the training of the clergy, particularly as lay lawyers began to emerge as a profession, with a humanist emphasis on educating the future ruling class for their duties. The growing humanist-inspired emphasis on education cumulated with the passing of the Education Act 1496, thought to have been steered through parliament by the Keeper of the Privy Seal William Elphinstone, Bishop of Aberdeen, which decreed that all sons of barons and freeholders of substance should attend grammar schools to learn "perfyct Latyne". All this resulted in an increase in literacy, which was largely concentrated among a male and wealthy elite, with perhaps 60 per cent of the nobility being literate by the end of the period.
 From the end of the eleventh century, universities had been founded across Europe, developing as semi-autonomous centres of learning, often teaching theology, mathematics, law and medicine. Until the fifteenth century, those Scots who wished to attend university had to travel to England, to Oxford or Cambridge, or to the Continent. Just over 1,000 students have been identified as doing so between the twelfth century and 1410. Among the destinations Paris was the most important, but also Cologne, Orléans, Wittenberg, Louvain and Vienna.
 Among these travelling scholars, the most important intellectual figure was John Duns Scotus (c. 1266–1308), who studied at Oxford, Cambridge and Paris. He probably died at Cologne in 1308, after becoming a major influence on late medieval religious thought. After the outbreak of the Wars of Independence (1296–1357), with occasional exceptions under safe conduct, English universities were closed to Scots and continental universities became more significant. Some Scottish scholars became teachers in continental universities. At Paris, this included John de Rait (died c.  1355) and Walter Wardlaw (died c. 1387) in the 1340s and 1350s, William de Tredbrum in the 1380s and Laurence de Lindores (1372–1437) in the early 1500s. The continued movement to other universities produced a school of Scottish nominalists at Paris in the early sixteenth century, of which John Mair (1467–1550) was a member. He had probably studied at a Scottish grammar school and then Cambridge, before moving to Paris where he matriculated in 1493.
 This situation was transformed by the founding of St John's College, St Andrews in 1418. Henry Wardlaw, bishop of St. Andrews, petitioned the anti-Pope Benedict XIII during the later stages of the Great Western Schism, when Scotland was one of his few remaining supporters. Wardlaw argued that Scottish scholars in other universities were being persecuted for their loyalty to the anti-Pope. St Salvator's College was added to St. Andrews in 1450. The other great bishoprics followed, with the University of Glasgow being founded in 1451 and the King's College, Aberdeen in 1495. Both were also papal foundations, by Nicholas V and Alexander VI respectively. St Leonard's College was added at St. Andrews in 1511. St. Andrews was deliberately modelled on Paris, and although Glasgow adopted the statues of the University of Bologna, there, like Aberdeen, there was an increasing Parisian influence, partly because all its early regents had been educated in Paris. Initially, these institutions were designed for the training of clerics, but they would increasingly be used by laymen who began to challenge the clerical monopoly of administrative posts in government and law. They provided only basic degrees. Those wanting to study for the more advanced degrees that were common amongst European scholars still needed to go to universities in other countries. As a result, Scottish scholars continued to visit the Continent and returned to English universities after they reopened to Scots in the late fifteenth century.
 
By the fifteenth century, beginning in northern Italy, universities had become strongly influenced by humanist thinking. This put an emphasis on classical authors, questioning some of the accepted certainties of established thinking and manifesting itself in the teaching of new subjects, particularly through the medium of the Greek language. However, in this period, Scottish universities largely had a Latin curriculum, designed for the clergy, civil and common lawyers. They did not teach the Greek that was fundamental to the new humanist scholarship, focusing on metaphysics and putting a largely unquestioning faith in the works of Aristotle, whose authority would be challenged in the Renaissance. Towards the end of the fifteenth century, a humanist influence was becoming more evident. A major figure was Archibald Whitelaw, a teacher at St. Andrews and Cologne who later became a tutor to the young James III and served as royal secretary from 1462 to 1493. By 1497, the humanist and historian Hector Boece, born in Dundee and who had studied at Paris, returned to become the first principal at the new university of Aberdeen. In 1518 Mair returned to Scotland to become Principal of the University of Glasgow. He transferred to St. Andrews in 1523 and in 1533 he was made Provost of St Salvator's College. While in Scotland his students included John Knox and George Buchanan. These international contacts helped integrate Scotland into a wider European scholarly world and would be one of the most important ways in which the new ideas of Humanism were brought into Scottish intellectual life in the sixteenth century.