Dunfermline (; Scots: Dunfaurlin, Scottish Gaelic: Dùn Phàrlain) is a town and former Royal Burgh, and parish, in Fife, Scotland, on high ground 3 miles (5 km) from the northern shore of the Firth of Forth. The town recorded a population of 50,380 in 2012, making it the most populous locality in Fife and the 11th most populous in Scotland.
The earliest known settlements in the area around Dunfermline probably date as far back as the Neolithic period. The area was not regionally significant until at least the Bronze Age. The town was first recorded in the 11th century, with the marriage of Malcolm III, King of Scots, and Saint Margaret at the church in Dunfermline. As his Queen consort, Margaret established a new church dedicated to the Holy Trinity, which evolved into an Abbey under their son, David I in 1128. During the reign of Alexander I, the church – later to be known as Dunfermline Abbey – was firmly established as a prosperous royal mausoleum for the Scottish Crown. A total of eighteen royals, including seven Kings, were buried here from Queen Margaret in 1093 to Robert Stewart, Duke of Albany in 1420. Robert The Bruce, otherwise known as Robert I, became the last of the seven Scottish Kings to be buried in 1329. His bones would eventually be re-discovered and re-buried in 1821, when the excavation of the grounds of what had formerly been the eastern section of the Abbey became the site for the new Abbey Church.
The town is a major service centre for west Fife. Dunfermline retains much of its historic significance, as well as providing facilities for leisure. Employment is focused in the service sector, with the largest employer being Sky UK. Other large employers in the area include Amazon (on-line retailer), Best Western (hotels), CR Smith (windows manufacturing), FMC Technologies (offshore energy), Lloyds and Nationwide (both financial services).