During the Great Northern War (1700-1721) Tsardom of Russia led a coalition again the Swedish Empire. Peter the Great (1672-1725) ruled the Tsardom of Russia and later (1721) the Russian Empire from 7 May 1882. Before 1696 he ruled together with his elder half-brother, Ivan IV.
After the Battle of Poltava (1709, in present-day Ukraine), the Swedish troops south and east of the Baltic Sea were evicted. In 1710 Riga, the last great city, is conquered by the Russians.
With the Treaty of Nystad the Great Northern War ended: Ingria (southern border area between Russia and Finland), Estonia and Livonia became integrated in the Russian Empire. Livonia, with capital Riga, is the northern part of present-day Latvia and the southern part of present-day Estonia.
The eastern part of present-day Latvia, Latgale, became part of the Russian government Pskov after the First Partition of Poland (1772). Later became it part of Plotsk, Belarus and -finally- government Vitebsk.
The southern part of present-day Latvia became the Russian Government Courland with capital Митава [Mitava] after the Third Partition of Poland (1795). The German name for Митава [Mitava] is Mitau and the present Latvian name is Jelgava.