the struggles continued, though the duchy was officially guaranteed freedom of religion by the 1648 peace of westphalia. after the death of the last piast duke, george william, in 1675, legnica passed to the direct rule of the habsburg emperor leopold i, despite claims raised by elector frederick william of brandenburg referring to the inheritance pact in 1537. for the prussian king frederick the great, the old dispute was a pretext to justify his campaign during the first silesian war: in 1742 most of silesia including legnica was occupied by the prussian army after empress maria theresa's defeat in the war of the austrian succession. finally in 1763 the duchy lost most of its privileges after being incorporated into prussia according to the peace of hubertusburg.