The town's name was first recorded as "Dunfermelitane" in the confirmation charters by David I in 1128.
The construction of six gates in Dunfermline in 1396 were to maintain the burgher's rights; the need for tolls and to a lesser extent to defend.