King of Bavaria was a title held by the hereditary Wittelsbach rulers of Bavaria in the state known as the Kingdom of Bavaria from 1805 until 1918, when the kingdom was abolished.
Under the terms of the Treaty of Pressburg concluded December 26, 1805 between Napoleonic France and Holy Roman Emperor Francis II, several principalities allied to Napoleon were elevated to kingdoms.
One of the staunchest of these had been the prince-elector of Bavaria, Maximilian IV Joseph, and on January 1, 1806, he formally assumed the title King Maximilian I Joseph of Bavaria.
He was a member of the Wittelsbach branch Palatinate-Birkenfeld-Zweibrücken.