With the defeat of Napoleon's France in 1814, Bavaria was compensated for some of its losses, and received new territories such as the Grand Duchy of Würzburg, the Archbishopric of Mainz (Aschaffenburg) and parts of the Grand Duchy of Hesse. Finally, in 1816, the Rhenish Palatinate was taken from France in exchange for most of Salzburg which was then ceded to Austria (Treaty of Munich (1816)). It was the second largest and second most powerful state south of the Main, behind only Austria. In Germany as a whole, it ranked third behind Prussia and Austria.