The 1805 Peace of Pressburg allowed Maximilian to raise Bavaria to the status of a kingdom. Accordingly, Maximilian proclaimed himself king on 1 January 1806. The King still served as an elector until Bavaria seceded from the Holy Roman Empire on 1 August 1806. The Duchy of Berg was ceded to Napoleon only in 1806. The new kingdom faced challenges from the outset of its creation, relying on the support of Napoleonic France. The kingdom faced war with Austria in 1808 and from 1810 to 1814, lost territory to Württemberg, Italy, and then Austria. In 1808, all relics of serfdom were abolished, which had left the old empire. In the same year, Maximilian promulgated Bavaria's first written constitution. Over the next five years, it was amended numerous times in accordance with Paris' wishes.