Holy Roman Empire
The empire was dissolved on 6 August 1806, when the last Holy Roman Emperor Francis II (from 1804, Emperor Francis I of Austria) abdicated, following a military defeat by the French under Napoleon at Austerlitz (see Treaty of Pressburg). Napoleon reorganized much of the Empire into the Confederation of the Rhine, a French satellite. Francis' House of Habsburg-Lorraine survived the demise of the empire, continuing to reign as Emperors of Austria and Kings of Hungary until the Habsburg empire's final dissolution in 1918 in the aftermath of World War I.
Electorate of Bavaria
The Wittelsbach dynasty which ruled the Duchy of Bavaria was the younger branch of the family which also ruled the Electorate of the Palatinate. The head of the elder branch was one of the seven prince-electors of the Holy Roman Empire according to the Golden Bull of 1356, but Bavaria was excluded from the electoral dignity. In 1621, the Elector Palatine Frederick V was put under the imperial ban for his role in the Bohemian Revolt against Emperor Ferdinand II, and the electoral dignity and territory of the Upper Palatinate was conferred upon his loyal cousin, Duke Maximilian I of Bavaria. Although the Peace of Westphalia would create a new electoral title for Frederick V's son, with the exception of a brief period during the War of the Spanish Succession, Maximilian's descendants would continue to hold the original electoral dignity until the extinction of his line in 1777. At that point the two lines were joined in personal union until the end of the Holy Roman Empire. In 1805, after the Peace of Pressburg, the then-elector, Maximilian Joseph, raised himself to the dignity of King of Bavaria, and the Holy Roman Empire was abolished the year after.