Riga remained one of the largest cities under the Swedish crown until 1710, a period during which the city retained a great deal of autonomous self-government. In July 1701, during the opening phase of the Great Northern War, the ''Crossing of the Düna'' took place nearby, resulting in a victory for king Charles XII of Sweden. Between November 1709 and June 1710, however, the Russians under Tsar Peter the Great besieged and captured Riga, which was at the time struck by a plague. Along with the other Livonian towns and gentry, Riga capitulated to Russia, but largely retained their privileges. Riga was made the capital of the Governorate of Riga (later: Livonia). Sweden's northern dominance had ended, and Russia's emergence as the strongest Northern power was formalised through the Treaty of Nystad in 1721. At the beginning of the 20th century Riga was the largest timber export port in the Russian Empire and ranked the 3rd according to the external trade volume. At the same time, Riga was also the third largest city in Russian Empire.