Dunfermline (i/dʌnˈfɜrmlɨn/; Scots: Dunfaurlin, Scottish Gaelic: Dùn Phàrlain) is a town and former Royal Burgh in Fife, Scotland, on high ground 3 miles (4.8 km) from the northern shore of the Firth of Forth. According to a 2010 estimate, Dunfermline has a population of 48,240, making it the second-biggest settlement in Fife. Part of the town's name comes from the Gaelic word, "dun" which translates as a fortified hill. The other parts, "ferm" and "lyn" are unclear, although "ferm" may have been an alternative name for the Tower Burn and "lyn", a pool or casade. Together, this may suggest the site of a fortification between the Ferm Burn and the Lyne Burn to the south.
The area around Dunfermline became home to the first settlers in the Neolithic period, but did not gain recognition until the Bronze Age as a place of importance. The town was first recorded in the 11th century, with the marriage of Malcolm III, King of Scotland, 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. Following the burial of Alexander I, the abbey graveyard confirmed its status as the mausoleum of Scotland's Kings and Queens.
The town is a major service centre for west Fife. Dunfermline retains much of its historic significance and provides numerous retail and leisure facilities. Carnegie College also have a campus at Halbeath. Employment is focused in the service sector, with the largest employer being BSKYB. Other large employers in the town include Amazon (on-line retailer), HBOS (finance), Taylor Wimpey (housebuilder), Dunfermline Building Society (finance) and CR Smith (window manufacturers).