Dunfermline 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. The 2011 census established that Dunfermline has a population of 49,706, making it the second-largest settlement in Fife.
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), FMC Technologies (subsea technology).
There have been various interpretations of the name, "Dunfermline". The first element, "dun" translated from Gaelic, has been accepted as a (fortified) hill, and is assumed to be referring to the rocky outcrop at the site of Malcolm Canmore's tower in Pittencrieff Glen (now Pittencrieff Park). The rest of the name is problematic. The second element, "the ferm" may have been an alternative name for the Tower Burn according to a medieval record published in 1455 and that, together with the Lyne Burn to the south, suggest the site of a fortification between these two watercourses.
The first record of a settlement in the Dunfermline area was in the Neolithic period. This evidence includes finds of a stone axe, some flint arrowheads and a carved stone ball which was found near the town. A cropmark which is understood to have been used as a possible mortuary enclosure has been found at Deanpark House, also near the town. By the time of the Bronze Age, the area was beginning to show some importance. Important finds included a bronze axe in Wellwood and a gold torc from the Parish Churchyard. Cist burials from the Bronze Age have also been discovered at both Crossford and Masterton, the latter of which contains a pair of armlets, a bronze dagger and a set necklace believed to have complemented a double burial.
The first historic record for Dunfermline was made in the 11th century. According to the fourteenth-century chronicler, John of Fordun, Malcolm III, King of Scotland (reign 1058–93) married his second bride, the Anglo-Hungarian princess, Saint Margaret, at the church in Dunfermline between 1068 and 1070; the ceremony was performed by Forhad, the last Celtic bishop of St Andrews. Malcolm III established Dunfermline as a new seat for royal power in the mid-11th century and initiated changes that eventually made the township the de facto capital of Scotland for much of the period until the assassination of James I in 1437. Following her marriage to King Malcolm III, Queen Margaret encouraged her husband to convert the small culdee chapel into a church for Benedictine monks. The existing culdee church was no longer able to meet the demand for its growing congregation because of a large increase in the population of Dunfermline from the arrival of English nobility coming into Scotland. The founding of this new church of Dunfermline was inaugurated around 1072, but was not recorded in the town's records.
King David I of Scotland (reigned 1124–53) would later grant this church, dedicated to the Holy Trinity, to "unam mansuram in burgo meo de Dunfermlyn" which translates into "a house or dwelling place in my burgh of Dunfermline". The foundations of the church evolved into an Abbey in 1128, under the reign of their son, David I. Dunfermline Abbey would play a major role in the general romanisation of religion throughout the kingdom. At the peak of its power the abbey controlled four burghs, three courts of regality and a large portfolio of lands from Moray in the north down into Berwickshire. Dunfermline had become a burgh between 1124 and 1127, if not before this time. Dunfermline Palace was also connected to the abbey and the first known documentation of the Auld Alliance was signed there on 23 October 1295.
The Union of the Crowns ended the town's royal connections when James VI relocated the Scottish Court to London in 1603. The Reformation of 1560 had previously meant a loss of the Dunfermline's ecclesiastical importance. On 25 May 1624, a fire engulfed around three-quarters of the medieval-renaissance burgh. Some of the surviving buildings of the fire were the palace, the abbey and the Abbot's House.
The decline in the fortunes of Dunfermline lasted until the introduction of a linen industry in the early 18th century. One reason for which the town became a centre for linen was there was enough water to power the mills and nearby ports along the Fife Coast. These ports also did trade with the Baltic and Low Countries. Another reason was through an act of industrial espionage in 1709 by a weaver known as James Blake who gained access to the workshops of a damask linen factory in Edinburgh by pretending to act like a simpleton in order to find out and memorise the formula. On his return to his home town in 1718, Blake established a damask linen industry in the town. The largest of these factories was St Leonard's Mill which was established by Erskine Beveridge in 1851. A warehouse and office block was later added around 1869. Other linen factories were built on land to both the north and south ends of the burgh. During the mid-19th century, powerloom weaving started to replace linen damask. The latter did not survive, going into decline straight after the end of First World War. In 1909 the Royal Navy established Scotland's only Royal Naval Dockyard at nearby Rosyth. Post-war housing began in the late 1940s with the construction of temporary prefabs and Swedish timber houses around areas such as Kingseat and Townhill. Additional provisions were made for electricity, water and sewage systems. Council housing was focused towards Abbeyview, on a site on Aberdour Road; Touch, to the south of Garvock Hill; Bellyeoman and Baldridgeburn. Private housing became focused to the north of Garvock Hill and on the site of West Pitcorthie Farm.
Today, Dunfermline is the main centre for the West Fife area, and is also considered to be a dormitory town for Edinburgh. The town has shopping facilities, a major public park, a main college campus at Halbeath and an-out-of-town leisure park with a multiplex cinema and a number of restaurants. The online retailer Amazon.com has opened a major distribution centre in the Duloch Park area of Dunfermline.