Countess of Flanders and Hainaut
At the death of her sister Joan in 1244, Margaret succeeded her as Countess of Flanders and Hainaut. Almost immediately, her sons from both marriages began the fight for the inheritance of the Counties, with the question of the validity of her first marriage to Bouchard of Avesnes was then raised, as if it was indeed illegitimate the inheritance of Flanders and Hainaut was passed only to the children from her second marriage, already favored by Margaret in 1245 when she paid homage to King Louis IX of France: at that point, she tried to obtain from the French King the recognition of William of Dampierre, the eldest son of her second marriage, as sole heir, arguing that Pope Gregory IX declared her first marriage invalid on 31 March 1237 and thus her sons from this union were illegitimate.
In 1246 Louis IX, acting as an arbitrator, gave the right to inherit Flanders to the Dampierre children, and the rights to Hainaut to the Avesnes children. This would seem to have settled the matter, but neither party accepted the solomonic decision of the French King, while responding to the spirit of fairness of the monarch, it had a political effect clearly advantageous for the interests of France, to dislocate the county, and served to avoid war. However, in 1248 John of Avesnes took advantage of the departure of Louis IX and William of Dampierre for the Crusades, to initiate war against his mother, taking Hainaut and Alost with other surrounding Flemish lands.
Margaret, thinking that the inheritance disputes were finally over after her son William of Dampierre paid homage for Flanders as her co-ruler to both Louis IX (in October 1246) and Emperor Frederick II (in 1248), made the political mistake of obtaining from the Pope, in 1251, the legitimation of both John and Baldwin of Avesnes; this gave them rights of birth over the Counties.
The unexpected death of William of Dampierre (6 June 1251) –who reportedly died from injuries received during a tournament, although his mother suspected that the allies of Avesnes were responsible– caused the renewal of the hostilities when John of Avesnes, who was uneasy about his rights, convinced William II of Holland, the German King recognized by the pro-papal forces, to seize Hainaut and the parts of Flanders which were within the bounds of the Holy Roman Empire. William II was theoretically, as King, overlord of these territories, and also John's brother-in-law. A civil war followed, which ended when the Avesnes forces defeated and imprisoned Guy of Dampierre (who had succeeded his brother as co-ruler of Flanders) at Westkappel, on the island of Walcheren, in July 1253.
Margaret offered the County of Hainaut to Charles of Anjou (brother of Louis IX) in order to obtain his military intervention against William II. Charles besieged Valenciennes, but a truce was negotiated between all parties on 26 July 1254, which included an agreement to submit the dispute to Louis IX for adjudication. Guy of Dampierre was ransomed in 1256 and Louis IX confirmed his 1246 decision regarding the Hainaut-Flanders split between the Avesnes and Dampierre children, while Charles of Anjou renounced to all his claims over Hainaut. The death of John of Avesnes in 1257 put a temporary halt over the already costly internecine quarrel.
The chronicler Matthew Paris called Margaret "...a new Medea guilty of the death of many honest knights". He related that after the capture of Guy and John of Dampierre at Westkappel, John of Avesnes sought to use them as hostages to force his mother to negotiate peace; supposedly, the harsh response of the Countess was:
Sacrifice them, truculent meat eater, and devour one of them cooked with pepper sauce and the other roasted with garlic.
Because the Avesnes heir, her grandson John II was still under-age, Margaret managed to recover the government of Hainaut, while in Flanders she remained co-ruler with her son Guy of Dampierre until 29 December 1278, when she abdicated in his favor. She administered Hainaut as solely ruling countess until May 1279, when she appointed John II as her co-ruler in Hainaut. She died nine months later, in February 1280. John II of Avesnes succeeded her as sole Count of Hainaut.
Margaret's death ended the personal union between Flanders and Hainaut, which had lasted for nearly a century. The two counties were reunited again only in 1432 when Jacqueline of Bavaria, the Avesnes heiress, surrendered her domains to Philip III, Duke of Burgundy, the Dampierre heir.