The Kingdom of Bavaria was a German state that succeeded the former Electorate of Bavaria in 1805 and continued to exist until 1918. With the unification of Germany into the German Empire in 1871, the kingdom became a federated state of the new empire and was second in size, power, and wealth only to the leading state, the Kingdom of Prussia.
The polity's foundation dates back to the ascension of prince-elector Maximilian IV Joseph of the House of Wittelsbach as King of Bavaria. The crown would go on being held by the Wittelsbachs until the kingdom came to an end in 1918. Most of the border of modern Germany's Free State of Bavaria were established after 1814 with the Treaty of Paris, in which the Kingdom of Bavaria ceded Tyrol and Vorarlberg to the Austrian Empire while receiving Aschaffenburg and Würzburg.
In 1918, Bavaria became a republic after the German Revolution, and the kingdom was thus succeeded by the current Free State of Bavaria.