Germanic peoples have inhabited Sweden since prehistoric times, emerging into history as the Geats () and Swedes () and constituting the sea peoples known as the Norsemen. An independent Swedish state emerged during the early 12th century. After the Black Death in the middle of the 14th century killed about a third of the Scandinavian population, the dominance of the Hanseatic League in Northern Europe threatened Scandinavia economically and politically. This led to the forming of the Scandinavian Kalmar Union in 1397, which Sweden left in 1523. When Sweden became involved in the Thirty Years' War on the Protestant side, an expansion of its territories began and eventually the Swedish Empire was formed. This became one of the great powers of Europe until the early 18th century. Swedish territories outside the Scandinavian Peninsula were gradually lost during the 18th and 19th centuries, ending with the annexation of present-day Finland by Russia in 1809. The last war in which Sweden was directly involved was in 1814 when Norway was militarily forced into a personal union, which peacefully dissolved in 1905. Since then, Sweden has been at peace, maintaining an official policy of neutrality in foreign affairs. In 2014, Sweden celebrated 200 years of peace, breaking even Switzerland's record for peace. Sweden was formally neutral through both world wars and the Cold War, albeit Sweden has since 2009 openly moved towards cooperation with NATO.