In 1071 William defeated the last rebellion of the north. Earl Edwin was betrayed by his own men and killed, while William built a causeway to subdue the Isle of Ely, where Hereward the Wake and Morcar were hiding. Hereward escaped, but Morcar was captured, deprived of his earldom, and imprisoned. In 1072 William invaded Scotland, defeating Malcolm, who had recently invaded the north of England. William and Malcolm agreed to peace by signing the Treaty of Abernethy, and Malcolm probably gave up his son Duncan as a hostage for the peace. Perhaps another stipulation of the treaty was the expulsion of Edgar the Ætheling from Malcolm's court. William then turned his attention to the continent, returning to Normandy in early 1073 to deal with the invasion of Maine by Fulk le Rechin, the Count of Anjou. With a swift campaign, William seized Le Mans from Fulk's forces, completing the campaign by 30 March 1073. This made William's power more secure in northern France, but the new count of Flanders accepted Edgar the Ætheling into his court. Robert also married his half-sister Bertha to King Philip I of France, who was opposed to Norman power.