Agriculture in Scotland in the Middle Ages includes all forms of farm production in the modern boundaries of Scotland, between the departure of the Romans from Britain in the fifth century and the establishment of the Renaissance in the early sixteenth century. Scotland has between a fifth and a sixth of the amount of the arable or good pastoral land of England and Wales, mostly located in the south and east. Heavy rainfall encouraged the spread of acidic blanket peat bog, which with wind and salt spray, made most of the western islands treeless. The existence of hills, mountains, quicksands and marshes made internal communication and agriculture difficult. Most farms had to produce a self-sufficient diet of meat, dairy products and cereals, supplemented by hunter-gathering. The early Middle Ages were a period of climate deterioration resulting in more land becoming unproductive. Farming was based around a single homestead or a small cluster of three or four homes, each probably containing a nuclear family and cattle were the most important domesticated animal.
 In the period 1150 to 1300, warm dry summers and less severe winters allowed cultivation at much greater heights and made land more productive. Arable farming grew significantly, but was still more common in low-lying areas than in high-lying areas such as the Highlands, Galloway and the Southern Uplands. The system of infield and outfield agriculture, a variation of open-field farming widely used across Europe, may have been introduced with feudalism from the twelfth century. Crops were bere (a form of barley), oats and sometimes wheat, rye and legumes. Hunting reserves were adopted by Anglo-Norman lords and then by Gaelic ones. The more extensive outfield was used for oats. New monastic orders such as the Cistercians became major landholders and sheep farmers, particularly in the Borders where they were organised in granges.
 By the late Medieval period, most farming was based on the Lowland fermtoun or Highland baile, settlements of a handful of families that jointly farmed an area notionally suitable for two or three plough teams, allocated in run rigs to tenant farmers, known as husbandmen. Runrigs usually ran downhill so that they included both wet and dry land. Most ploughing was done with a heavy wooden plough with an iron coulter, pulled by oxen, which were more effective and cheaper to feed than horses. Key crops included kale, hemp and flax. Sheep and goats were probably the main sources of milk, while cattle were raised for meat. The rural economy appears to have boomed in the thirteenth century and in the immediate aftermath of the Black Death was still buoyant, but by the 1360s there was a severe falling off in incomes to be followed by a slow recovery in the fifteenth century.
 Scotland is roughly half the size of England and Wales and has approximately the same amount of coastline, but only between a fifth and a sixth of the amount of the arable or good pastoral land, under 60 metres above sea level, and most of this is located in the south and east. This made marginal pastoral farming and fishing, the key factors in the pre-modern economy. Its east Atlantic position means that it has moderate rainfall: today about 700 mm per year in the east and over 1,000 mm in the west. This encouraged the spread of blanket peat bog, the acidity of which, combined with high level of wind and salt spray, made most of the western islands treeless. The existence of hills, mountains, quicksands and marshes made agriculture and internal communication difficult. The relative importance of climate and human interference has been debated, but Scotland was certainly much more heavily forested before humans arrived, around 5000 BP; for example, the Outer Hebrides were wooded "down to the western shoreline", implying that climate alone does not explain Scotland's low tree cover.
 The early Middle Ages, from the fifth century to the tenth century, were a period of climate deterioration, with a drop in temperature and an increase in rainfall, resulting in more land becoming unproductive. With a lack of significant transport links and wider markets, most farms had to produce a self-sufficient diet of meat, dairy products and cereals, supplemented by hunter-gathering. Limited archaeological evidence indicates that farming was based around a single homestead or a small cluster of three or four homes, each probably containing a nuclear family, with kinship relationships likely to be common among neighbouring houses and settlements, reflecting the partition of land through inheritance. The climate meant that more oats and barley were grown than wheat. The evidence of bones indicates that cattle were by far the most important domesticated animal, followed by pigs, sheep and goats, while domesticated fowl were very rare. Christian missionaries from Ireland may have changed agricultural practice, bringing innovations such as the horizontal watermill and mould board ploughs, which were more effective in turning the soil.
 In the period 1150 to 1300, warm dry summers and less severe winters of the Medieval Warm Period allowed cultivation at much greater heights above sea level and made land more productive. Arable farming grew significantly, but was still more common in low-lying areas in the south and east than in high-lying areas such as the Highlands, Galloway and the Southern Uplands. The feudalism introduced under David I, particularly in the east and south where the crown's authority was greatest, saw the placement of baronial lordships. Land was now held from the king, or a superior lord, in exchange for loyalty and forms of service that were usually military. Barons, who held feudal tenures, had the right to hold baronial courts, which could deal with matters of land ownership. However, the imposition of feudalism continued to sit beside the existing systems of landholding and tenure and it is not clear how this change impacted on the lives of the ordinary free and unfree workers. In places, feudalism may have tied workers more closely to the land. However, the predominantly pastoral nature of Scottish agriculture may have made the imposition of a manorial system, based on the English model, impracticable in some areas. Obligations appear to have been limited to occasional labour service, seasonal renders of food, hospitality and money rents. They usually included supplying oxen for ploughing the lord's land on an annual basis and the much resented obligation to grind corn at the lord's mill.
 Hunting reserves were adopted by Anglo-Norman lords and then by Gaelic ones, creating large tracts of land reserved for the leisure of the aristocracy and nobility. These were less rigorously enforced than in England, where the taking of wood and game were strictly forbidden, and all royal forests were on land already in the king's hands. The introduction of new monastic orders such as the Cistercians in this period also brought innovations in agriculture. Particularly in the Borders, their monasteries became major landholders, sheep farmers and producers of wool for the markets in Flanders. These were organised in granges, monastic farms run by lay brothers of the order. Granges were theoretically within 30 miles of the mother monastery, so that those working there could return for services on Sundays and feast days. They were used for variety of purposes, including pastoral, arable and industrial production. However, to manage more distant assets in Ayrshire, Melrose Abbey used Mauchline as a "super grange", to oversee lesser granges. Some abbeys like Melrose had at least 12,000 sheep in the late thirteenth century.
 The system of infield and outfield agriculture, a variation of open field farming widely used across Europe, may have been introduced with feudalism and would continue until the eighteenth century. This expanded from the use of small enclosed fields, which continued from the prehistoric era. The infield was the best land, close to housing. It was farmed continuously and most intensively, receiving most of the manure. Crops were usually bere (a form of barley), oats and sometimes wheat, rye and legumes. The more extensive outfield was used for largely for oats. It was fertilised from the overnight folding of cattle in the summer and was often left fallow to recover its fertility. In fertile regions the infield could be extensive, but in the uplands it might be small, surrounded by large amounts of outfield. In coastal areas fertiliser included seaweed and around the major burghs urban refuse was used. Yields were fairly low, often around three times the quantity of seed sown, although they could reach twice that yield on some infields. The main unit of land measurement in Scotland was the davoch (i.e. "vat"), called the arachor in Lennox. This unit is also known as the "Scottish ploughgate". In English-speaking Lothian, it was simply a ploughgate. It may have measured about 104 acres (0.42 km2), divided into 4 raths or eight oxgangs, the area that eight oxen were said to be able to plough in one year.
 By the fourteenth century most farming was based on the Lowland fermtoun or Highland baile, settlements of a handful of families that jointly farmed an area notionally suitable for two or three plough teams. These were allocated in run rigs to tenant farmers, who were usually known as husbandmen or bonders. The average amount of land used by a husbandman in Scotland, known as a husbandland, was 26 acres, or 2 oxgangs. They would also have had a share of hay meadow and common pasture. Below the husbandmen, lesser landholders and free tenants, were the cottars, who often shared rights to common pasture, occupied small portions of land and participated in joint farming as hired labour. Farms also might have grassmen, who had rights only to grazing. Pasture was often accessed by shieling-grounds, with shelters made of stone or turf, used for the grazing of cattle in summer. These would often be distant from the main settlements in the Lowlands, but might be relatively close in the more remote Highlands.
 Runrigs, were a ridge and furrow pattern, similar to that used in parts of England, with alternating "runs" (furrows) and "rigs" (ridges). They usually ran downhill so that they included both wet and dry land, helping to offset some of the problems of extreme weather conditions. Most ploughing was done with a heavy wooden plough with an iron coulter, pulled by oxen, which were more effective on heavy soils and cheaper to feed than horses. They were usually pulled by a team of eight oxen, which would have taken four men to operate and only covered half an acre a day.
 Key crops included kale (for both humans and animals), and hemp and flax for cloth production. Sheep and goats were probably the main sources of milk, while cattle were raised primarily for meat. The rural economy appears to have boomed in the thirteenth century and in the immediate aftermath of the Black Death, which reached Scotland in 1349 and may have killed a third of the population, was still buoyant, but by the 1360s there was a severe falling off in incomes that can be seen in clerical benefices, of between a third and half compared with the beginning of the era. This was followed by a slow recovery in the fifteenth century. Towards the end of the period average temperatures began to reduce again, with the cooler and wetter conditions of the Little Ice Age limiting the extent of arable agriculture, particularly in the Highlands.