Emperor
The first Austrian Emperor was the last Holy Roman Emperor Francis II. In the face of aggressions by Napoleon, Francis feared for the future of the Holy Roman Empire. He wished to maintain his and his family's Imperial status in the event that the Holy Roman Empire should be dissolved, as it indeed was in 1806 when an Austrian-led army suffered a humiliating defeat at the Battle of Austerlitz. After which, the victorious Napoleon proceeded to dismantle the old "Reich" by severing a good portion from the empire and turning it into a separate Confederation of the Rhine. With the size of his imperial realm significantly reduced, Francis II, "Holy Roman Emperor" became Francis I, "Emperor of Austria". The new imperial title may have sounded less prestigious than the old one, but Francis' dynasty continued to rule from Austria and a Habsburg monarch was still an emperor ("Kaiser"), and not just merely a king ("König"), in name.
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.