Peter the Great
After that Russia invaded Sweden and conquered  Estonia, Livonia, and Finland.  By 1719 Russia had conquered all of Sweden. Even though Sweden had clearly lost, they did not give up until 1721. In 1721 Sweden  signed the Treaty of Nystad where they agreed to give Estonia, Livonia and Ingria to Russia.