In 1756, during the Third Silesian War between Prussia and Austria (part of the Seven Years' War), Saxony was invaded and overrun by the forces of King Frederick II of Prussia, who took Dresden and after the Siege of Pirna forced the Saxon army to surrender and join his Prussian Army. Many later deserted, and a force of Saxon troops fought to restore their independence. The Treaty of Hubertusburg in 1763 eventually restored Saxony as an entity.