The uprising began a period in Polish history known as The Deluge (which included the Swedish invasion of the Commonwealth during the Second Northern War of 1655-1660), that temporarily freed the Ukrainians from Polish domination but in a short time subjected them to Russian domination. Weakened by wars, in 1654 Khmelnytsky persuaded the Cossacks to ally with the Russian tsar in the Treaty of Pereyaslav, which led to the Russo-Polish War (1654–1667). When Poland–Lithuania and Russia signed the Truce of Vilna and agreed on an anti-Swedish alliance in 1657, Khmelnytski's Cossacks supported the invasion of the Commonwealth by Sweden's Transylvanian allies instead. Although the Commonwealth tried to regain its influence over the Cossacks (note the Treaty of Hadiach of 1658), the new Cossack subjects became even more dominated by Russia. With the Commonwealth becoming increasingly weak, Cossacks became more and more integrated into the Russian Empire, with their autonomy and privileges eroded. The remnants of these privileges were gradually abolished in the aftermath of the Great Northern War (1700-1721) in which hetman Ivan Mazepa sided with Sweden. By the time that the last of the partitions of Poland ended the existence of the Commonwealth in 1795, many Cossacks had already left Ukraine to colonise the Kuban and, in process, Russified themselves.