In the pretext of the Great Northern War, August the Strong of Saxe-Poland-Lithuania and Peter the Great of Russia had agreed to conquer and partition Sweden's Baltic dominions in the Treaty of Preobrazhenskoye in 1699. During the war, Charles XII of Sweden was able to defeat the Russian army at Narva in 1700, and then pursued August the Strong to Saxony. Once the main Swedish army was gone, Russian forces were able to regroup and conquered most of the plague-stricken Baltic provinces until 1710, when the last Swedish strongholds Riga, Reval and Pernau capitulated. At this time, the main Swedish army was captured at the Surrender at Perevolochna following the Battle of Poltava. Peter the Great had in person launched the first shells in the siege of Riga, in November 1709.