The Kingdom of Bavaria was a German state that succeeded the former Electorate of Bavaria in 1805 and continued to exist until 1918. The Bavarian Elector Maximilian IV Joseph of the House of Wittelsbach became the first King of Bavaria in 1805 as Maximilian I Joseph. The crown would go on being held by the Wittelsbachs until the kingdom came to an end in 1918. Most of Bavaria's present-day borders were established after 1814 with the Treaty of Paris, in which Bavaria ceded Tyrol and Vorarlberg to the Austrian Empire while receiving Aschaffenburg and Würzburg. 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. In 1918, Bavaria became a republic after the German Revolution, and the kingdom was thus succeeded by the current Free State of Bavaria.