According to tradition, the widowed Agatha decided to leave Northumbria, England with her children and return to the continent. However, a storm drove their ship north to the Kingdom of Scotland in 1068, where they sought the protection of King Malcolm III. The locus where it is believed that they landed is known today as St Margaret's Hope, near the village of North Queensferry, Fife, Scotland. Margaret's arrival in Scotland, after the failed revolt of the Northumbrian earls, has been heavily romanticized, though Symeon of Durham implied that her first meeting of Malcolm III may not have been until 1070, after William the Conqueror's Harrying of the North.

King Malcolm III was a widower with two sons, Donald and Duncan. He would have been attracted to marrying one of the few remaining members of the Anglo-Saxon royal family. The marriage of Malcolm and Margaret occurred in 1070. Subsequently, Malcolm executed several invasions of Northumberland to support the claim of his new brother-in-law Edgar and to increase his own power. These, however, had little effect save the devastation of the County.