Treaty of Nystad
Sweden's defeat by Russia in the Great Northern War resulted in the capitulation of Estonia and Livonia in 1710, confirmed by the Treaty of Nystad in 1721, and Russian rule was then imposed on what later became modern Estonia. Nonetheless, the legal system, Lutheran church, local and town governments, and education remained mostly German until the late 19th century and partially until 1918.