In the Imperial City of Nuremberg, on 29 November 1225, the 21-year-old Margaret was married to the 14-year-old Henry, eldest son of Emperor Frederick II and elected King of the Romans since 1222. Frederick's counsellor Archbishop Engelbert of Cologne had initially planned for a bride from the English royal Angevin dynasty, however, the attempt failed, as did Henry's former engagement with the Přemyslid princess Agnes, daughter of King Ottokar I of Bohemia. Margaret's coronation as Queen of the Romans took place on 23 March 1227 in Aachen Cathedral. King Henry and Queen Margaret had two short-lived sons, Henry and Frederick. In 1228, Henry took over the rule in the German kingdom and tried to limit the powers of the princes, thereby disturbing the Imperial policies of his father who made him pay homage under the threat of excommunication. In 1235, Henry allied with the princely opposition and openly rebelled against the emperor, however, was defeated by his father's forces and dethroned. Frederick had him confined in several castles in Apulia, where he died on 12 February 1242 after a fall from his horse, probably in an attempted suicide. In the meanwhile, his wife Margaret retired to the Dominican monastery in Trier and in 1244 moved to Würzburg, where she lived in seclusion in St Marcus Abbey.
Claim to Austria and Styria
In 1246 Margaret's brother Duke Frederick II of Austria, last scion of the Babenberg dynasty, died childless in the Battle of the Leitha River, leaving a succession crisis. The two principal claimants over the succession in the duchies of Austria and Styria were two women: Margaret and her niece Gertrude, who claimed primogeniture, as the only daughter of Henry of Mödling, the eldest brother of the late Duke Frederick II, who had predeceased their father Duke Leopold VI. As King Wenceslaus I of Bohemia wanted to take control over the duchies south of his realm, he arranged for the wedding of his eldest son and heir, Margrave Vladislaus III of Moravia, with Gertrude. The couple was even proclaimed Duke and Duchess of Austria, but Vladislaus died in the following year. The next ruler of Austria was Gertrude's second husband, Margrave Herman VI of Baden, who died in 1250, leaving Austria and Styria princeless again.
Second marriage
The Austrian aristocracy offered the government of the duchies to King Wenceslaus' second son and new heir apparent Ottokar II. However, one condition was imposed by the nobles: Ottokar could only take control of Austria and Styria if he married one of the Babenberg heiresses. Ottokar refused to marry his brother's widow, such marriage being prohibited by the Book of Leviticus, and decided to marry Margaret, 26 years his senior. The ceremony took place on 11 February 1252 in the Castle Chapel of Hainburg an der Donau. Ottokar acquired the imperial privileges sealed with a Golden Bull on the basis of the Privilegium Minus, acknowledged by Emperor Frederick II, which legitimized his claim over Austria and Styria, since Margaret was the heiress of the last duke by proximity of blood. Thereby she transferred the government of the duchies to Austria and Styria to her husband. Pope Innocent IV, who had previously changed sides several times between Gertrude and Margaret, confirmed the lawful government of Ottokar over both duchies on 6 May 1252. Bohemian administrators ruled the duchies in his name. One year later, on 23 September 1253, King Wenceslaus I died, and Ottokar and Margaret became King and Queen of Bohemia. Once he had obtained the Babenberg duchies, it was evident to Ottokar that Margaret, already 50 years old, would not bear children. The king tried to gain from the Pope the recognition of the illegitimate son whom he had with Agnes of Kuenring, one of Margaret's ladies-in-waiting, as his lawful successor. After the Pope refused this, in 1261 Ottokar obtained the annulment of his marriage with Margaret.
Later life
While Ottokar married Kunigunda of Halych, a grand-daughter of King Béla IV of Hungary, the repudiated Queen Margaret left Bohemia and returned to her Austrian homeland. She took her residence in Krumau am Kamp, spending the winters in Krems. After the annulment she was called Romanorum quondam Regina ; however, she maintained the title ducissa Austrie et Stirie. In 1266 she changed her title to quondam filia Livpoldi illustris ducis Austrie et Stirie et Romanorum Regina as a reference to her father. Prior to her death in Krumau, she chose Lilienfeld Abbey as her burial place, next to her father. The date of her death is controversial. Some sources state 1266, while others state 2/12 October 1267 as the real date. King Ottokar II kept Austria, Styria; he also acquired the Duchy of Carinthia with the March of Carniola in 1269, claiming to be the heir designated by Margaret in their divorce settlement. He even stood as a candidate for the Imperial Crown several times, until he was deposed by King Rudolf I of Germany in 1276 and killed in the Battle on the Marchfeld two years later.