The Kingdom of Bavaria (; ; spelled Baiern until 1825) 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 in 1805. The crown continued to be 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. History Foundation and expansion under Maximilian I On 30 December 1777, the Bavarian line of the Wittelsbachs became extinct, and the succession on the Electorate of Bavaria passed to Charles Theodore, the Elector Palatine. After a separation of four and a half centuries, the Palatinate, to which the duchies of Jülich and Berg had been added, was thus reunited with Bavaria. In 1793, French revolutionary armies overran the Palatinate; in 1795, the French, under Moreau, invaded Bavaria itself, advanced to Munich—where they were received with joy by the long-suppressed Liberals—and laid siege to Ingolstadt. Charles Theodore, who had done nothing to prevent wars or to resist the invasion, fled to Saxony, leaving a regency, the members of which signed a convention with Moreau, by which he granted an armistice in return for a heavy contribution (7 September 1796). Between the French and the Austrians, Bavaria was now in a bad situation. Before the death of Charles Theodore (16 February 1799), the Austrians had again occupied the country, in preparation for renewing the war with France. Maximilian IV Joseph (of Zweibrücken), the new elector, succeeded to a difficult inheritance. Though his own sympathies, and those of his all-powerful minister, Maximilian von Montgelas, were, if anything, French rather than Austrian, the state of the Bavarian finances, and the fact that the Bavarian troops were scattered and disorganized, placed him helpless in