The Treaty of Teschen (, i.e., "Peace of Teschen"; ) was signed on 13 May 1779 in Teschen, then in Austrian Silesia, between the Austrian Habsburg monarchy and the Kingdom of Prussia, which officially ended the War of the Bavarian Succession. Background When the childless Wittelsbach elector Maximilian III Joseph of Bavaria died in 1777, the Habsburg emperor Joseph II sought to acquire most of the Electorate of Bavaria and the Upper Palatinate, basing his claim on his marriage with the late elector's sister, Maria Josepha, who had died in 1767. Maximilian's direct heir was his distant cousin Count Palatine and Prince-Elector Charles Theodore (1724–1799), by prior succession agreements between the Bavarian and Palatinate branches of the Wittelsbach dynasty. Charles Theodore was amenable to an agreement with Emperor Joseph II that would allow him to acquire parts of the Austrian Netherlands in exchange for parts of his Bavarian inheritance. From 16 January 1778 Austrian troops moved into the Lower Bavarian lands of Straubing. Ultimately, both parties envisioned a wholesale exchange of the Bavarian lands for the Austrian Netherlands, but the final details were never concluded by treaty due to outside intervention. Charles Theodore too had no legitimate heirs, so his prospective successor was his Palatine cousin, Duke Charles II August of Zweibrücken (1746–1795). Charles August objected to an agreement which would deprive him of the Bavarian inheritance; he appealed to the Imperial Diet in Regensburg. His cause was taken up by the Prussian king Frederick the Great, who refused any increase in Austrian territory, and by Saxony, whose Wettin electoral house had married into the Wittelsbach family and therefore had allodial claims to parts of the inheritance. The War of the Bavarian Succession broke out with the invasion of the Prussian Army into Bohemia on 5 July 1778, after Austria and Prussia could not negotiate a solution to their differences. Due to difficulties in supplying the troops, the war became a stalemate: the Prussians were not able to advance far into the Bohemian lands, but the Austrians were unwilling to invade Saxony or Prussia. This was partly because Empress Maria Theresa (the mother of Joseph II and his co-ruler as Queen of Bohemia and Archduchess of Austria) firmly opposed the war after it became clear that a stalemate prevailed. She dispatched peace initiatives to King Frederick II of Prussia and forced her son to accept mediation by France and Russia.