|This article needs additional or better citations for verification. (January 2017) (Learn how and when to remove this template message)|
Dunfermline was a favourite residence of many Scottish monarchs. Documented history of royal residence there begins in the 11th century with Malcolm III who made it his capital. His seat was the nearby Malcolm's Tower, a few hundred yards to the west of the later palace. In the medieval period David II and James I of Scotland were both born at Dunfermline.
Dunfermline Palace is attached to the historic Dunfermline Abbey, occupying a site between the abbey and deep gorge to the south. It is connected to the former monastic residential quarters of the abbey via a gatehouse above a pend (or yett), one of Dunfermline's medieval gates. The building therefore occupies what was originally the guest house of the abbey. However, its remains largely reflect the form in which the building was developed by James IV in a refabrication around 1500. Throughout the sixteenth century, Scotland's monarchs and royal family members were frequently in residence.
In 1589 the palace was given as a wedding present by the king, James VI, to Anne of Denmark after their marriage. She gave birth to three of their children there; Elizabeth (1596), Charles (1600) and Robert (1602).
After the Union of Crowns in 1603, the removal of the Scottish court to London meant that the building came to be rarely visited by a monarch. Ten tapestries from the royal tapestry collection were still there in 1616, left from the time the infant Prince Charles resided at the Palace. When Charles I returned in 1633 for his Scottish coronation he only made a brief visit to his place of birth. The last monarch to occupy the palace was Charles II who stayed at Dunfermline in 1650 just before the Battle of Pitreavie. Soon afterwards, during the Cromwellian occupation of Scotland, the building was abandoned and by 1708 it had been unroofed.