By the Treaty of Oliva between Poland and Sweden in 1660 following the Northern Wars the Polish king renounced all claims to the Swedish throne and Livonia was formally ceded to Sweden.
By the peace treaties of Brömsebro (1645) and Roskilde (1658) the Realm of Sweden expanded to the south.
According to the peace treaties the country was to retain its old laws and privileges, and was initially administered as a dominion.