The history of agriculture in Scotland includes all forms of farm production in the modern boundaries of Scotland, from the prehistoric era to the present day.
Scotland's good arable and pastoral land is found mostly in the south and east of the country. Heavy rainfall, wind and salt spray, in combination with thin soil and overgrazing, made most of the western islands treeless. The terrain often made internal land communication difficult, encouraging a coastal network. In the Neolithic period, from around 6,000 years ago, there is evidence of permanent settlements and farming. The two main sources of food were grain and cow milk. From the Bronze Age, arable land spread at the expense of forest. From the Iron Age, there were hill forts in southern Scotland associated with cultivation ridges and terraces and the fertile plains were already densely exploited for agriculture. During the period of Roman occupation of Britain there was re-growth of trees indicating a reduction in agriculture.
The early Middle Ages were a period of climate deterioration, resulting in more land becoming unproductive. Self-sufficient farms were based around a single homestead or a small cluster of homes. Oats and barley were grown more than other grains, and cattle were the most important domesticated animal. From c. 1150 to 1300, warm dry summers and less severe winters allowed cultivation at greater heights and made land more productive. The system of infield and outfield agriculture may have been introduced with feudalism from the twelfth century. By the late Medieval period, most farming was based on the Lowland fermtoun or Highland baile. These were settlements of a handful of families that jointly farmed an area notionally suitable for two or three plough teams, organised in run rigs. Most ploughing was done with a heavy wooden plough with an iron coulter, pulled by oxen. The rural economy 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.
As feudal distinctions declined in the early modern era, the major landholding orders, or heritors, were the lairds and yeomen. Others with property rights included husbandmen and free tenants. Many young people left home to become domestic and agricultural servants. The early modern era also saw the impact of the Little Ice Age, necessitating the shipping of large quantities of grain from the Baltic. Under the Commonwealth, the country was relatively highly taxed, but gained access to English markets. After the Restoration customs duties with England were re-established. Economic conditions were generally favourable, as landowners promoted better tillage and cattle-raising. The closing decade of the seventeenth century saw a slump, followed the failed harvests of the "seven ill years", but these shortages would be the last of their kind. After the Union of 1707 there was a conscious attempt to improve agriculture among the gentry and nobility. Enclosure displaced the run rig system and free pasture. The resulting Lowland Clearances saw hundreds of thousands of cottars and tenant farmers from central and southern Scotland forcibly removed. The later Highland Clearances saw the displacement of much of the population of the Highlands as lands were enclosed for sheep farming. Those that remained many were now crofters, living on very small, rented farms with indefinite tenure, dependent on kelping, fishing, spinning of linen and military service. Scotland suffered its last major subsistence crisis when the potato blight reached the Highlands in 1846.
In the twentieth century Scottish agriculture became susceptible to world markets. There were dramatic price rises in the First World War, but a slump in the 1920s and 1930s, followed by more rises in the Second World War. In 1947 annual price reviews were introduced in an attempt to stabilise the market. There was a drive in UK agriculture to greater production until the late 1970s, resulting in intensive farming and increasing mechanisation. The UK joined the European Economic Community in 1972. Some sectors became viable only with subsidies. A series of reforms to the Common Agricultural Policy from the 1990s attempted to control over-production, limit incentives for intensive farming and mitigate environmental damage. A dual farm structure emerged with large commercial farms and small pluralised and diversified holdings.