Joseph I (July 26, 1678 – April 17, 1711) was Holy Roman Emperor and ruler of the Austrian Habsburg monarchy from 1705 until his death in 1711. He was the eldest son of Emperor Leopold I from his third wife, Eleonor Magdalene of Neuburg. Joseph was crowned King of Hungary at the age of nine in 1687 and was elected King of the Romans at the age of eleven in 1690. He succeeded to the thrones of Bohemia and the Holy Roman Empire when his father died.
Marriage and lack of heirs

Holy Roman Emperor Joseph I, King of Hungary, Bohemia and Croatia and Archduke of Austria
On February 24, 1699, he married Wilhelmine Amalia of Brunswick-Lüneburg in Vienna. Wilhelmine Amalia was the youngest daughter of Johann Friedrich, Duke of Brunswick-Calenberg, and Princess Benedicta Henrietta of the Palatinate of the Rhine.
They had three children and their only son, Archduke Leopold Joseph, died of hydrocephalus before his first birthday. Joseph had a passion for love affairs (none of which resulted in illegitimate children) and he caught a sexually transmittable disease, probably syphilis, which he passed on to his wife while they were trying to produce a new heir. This incident rendered her sterile.
The Mutual Pact of Succession was devised by Emperor Leopold I, on the occasion of Archduke Charles’s departure for Spain. It stipulated that the claim to the Spanish realms was to be assumed by Archduke Charles, while the right of succession to the rest of the Habsburg hereditary dominions would rest with his elder brother Archduke Joseph, thereby again dividing the House of Habsburg into two lines.
The Pact also specified the succession to the brothers: they would both be succeeded by their respective heirs male but should one of them fail to have a son, the other one would succeed him in all his realms.

Holy Roman Emperor Charles VI, King of Hungary, Bohemia and Croatia and Archduke of Austria
However, should both brothers die leaving no sons, the daughters of the elder brother (Joseph) would have absolute precedence over the daughters of the younger brother (Charles) and the eldest daughter of Joseph would ascend all the Habsburg thrones.
The Mutual Pact of Succession was secretly signed by archdukes Joseph and Charles of Austria, the future emperors of the Holy Roman Empire, in 1703.
In 1700 the senior line of the House of Habsburg became extinct with the death of King Carlos II of Spain. The War of the Spanish Succession ensued, with Louis XIV of France and Navarre claiming the throne of Spain for his grandson Philippe, Duke of Anjou and Holy Roman Emperor Leopold I claiming them for his son Archduke Charles.
The Kingdom of Portugal, Kingdom of England, Scotland, Ireland and the majority of the Holy Roman Empire endorsed Archduke Charles’s candidature for the Spanish throne.

King Felipe V of Spain
Archduke Charles, as King Carlos III, as he was known, disembarked for his kingdom in 1705, and stayed there for six years, only being able to exercise his rule in Catalonia.
During the smallpox epidemic of 1711, which killed Louis, le Grand Dauphin and three siblings of the future Holy Roman Emperor Franz I, Emperor Joseph became infected. He died on April 17 in the Hofburg Palace. He had previously promised his wife to stop having affairs, should he survive.
At this point Archduke Charles “Carlos III of Spain” returned to Vienna to assume the imperial crown where he was elected as Holy Roman Emperor Charles VI.
Not wanting to see Austria and Spain in personal union again, the new Kingdom of Great Britain withdrew its support from the Austrian coalition, and the War of the Spanish Succession culminated with the Treaties of Utrecht and Rastatt three years later. The former, ratified in 1713, recognised Philippe, Duke of Anjou as King Felipe V of Spain.