Bavaria was the first German kingdom to defect from Napoleon, signing the Treaty of Ried with Austria on October 8, 1813.
The treaty took Bavaria out of the Confederation of the Rhine, Napoleon’s system of German client and allied states, and brought it into the Sixth Coalition. In return, Austria guaranteed Bavaria’s sovereignty and existing territorial position. Bavaria formally declared war on France on October 14.
The defection came after Napoleon’s disastrous invasion of Russia and the renewed coalition campaign of 1813. Bavarian leaders, including Crown Prince Ludwig and General Carl Philipp von Wrede, increasingly judged that remaining loyal to France threatened the kingdom’s survival. The treaty weakened Napoleon’s strategic position just before the Battle of Leipzig.
Saxony is a common alternative answer, but King Frederick Augustus remained Napoleon’s ally through Leipzig. Württemberg and other German states changed sides later, making Bavaria the accepted answer.