 The Treaty of Hubertusburg in 1763 eventually restored Saxony as an entity.When in 1806 Napoleon began a war with Prussia, Saxony at first allied itself with his long-time rival, but afterwards joined Napoleon and entered the Confederation of the Rhine.Elector Frederick Augustus III (1763–1827) was formally the last Elector of Saxony.