The Administrator of Prussia, the grandmaster of the Teutonic Order Maximilian III, son of emperor Maximilian II died in 1618. When Maximilian died, Albert's line died out, and the Duchy of Prussia passed to the Electors of Brandenburg, forming Brandenburg-Prussia. Taking advantage of the Swedish invasion of Poland in 1655, and instead of fulfilling his vassal's duties towards the Polish Kingdom, by joining forces with the Swedes and subsequent treaties of Wehlau, Labiau, and Oliva, Elector and Duke Frederick William succeeded in revoking king of Poland's sovereignty over the Duchy of Prussia in 1660. The absolutist elector also subdued the noble estates of Prussia.