Great Northern War
Initially, the anti-Swedish alliance comprised Peter the Great of Russia, Frederik IV of Denmark-Norway and August the Strong, Elector of Saxony and King of the Polish-Lithuanian Commonwealth. Frederik IV and Augustus the Strong were forced out of the alliance in 1700 and 1706, respectively, but re-joined it in 1709. George I of Brunswick-Lüneburg (Hanover) and Great Britain joined the coalition in 1714 for Hanover, and 1717 for Britain, and Frederick William I of Brandenburg-Prussia in 1715. On the Swedish side were Holstein-Gottorp, between 1704 and 1710, several Polish and Lithuanian magnates under Stanisław Leszczyński, and between 1708 and 1710 Cossacks under Ivan Mazepa. The Ottoman Empire temporarily hosted Charles XII of Sweden and intervened against Peter the Great.
The war started with a three-fold attack on Holstein-Gottorp, Swedish-occupied Livonia and Swedish Ingria by Denmark-Norway, Saxony-Poland-Lithuania, and Russia respectively. Sweden parried the Danish and Russian attacks in the Peace of Travendal and the Battle of Narva (1700), and in a counter-offensive pushed Augustus the Strong's forces through Lithuania and Poland to Saxony, dethroning him on the way, and forcing him to acknowledge defeat in the Treaty of Altranstädt. Peter the Great had meanwhile recovered and gained ground in Sweden's Baltic provinces, where he cemented Russia's access to the Baltic Sea by founding Saint Petersburg. Charles XII now moved from Saxony to confront Peter, but the campaign ended with the destruction of the main Swedish army at Poltava and Charles XII's exile in Ottoman Bender. The Russian pursuit was halted at the Pruth by the Ottoman army.
After Poltava, the initial anti-Swedish coalition was re-established and subsequently joined by Hanover and Prussia. The remaining Swedish forces south and east of the Baltic Sea were evicted from those Swedish dominions, which the allies partitioned among themselves. Sweden proper was invaded by Denmark-Norway from the West and by Russia from the East. Though the Danish attacks were repulsed, Russia managed to occupy Finland and inflict severe losses on the Swedish navy and coastal fortresses. Charles XII then opened up a Norwegian front, but was killed in Fredriksten in 1718.
The war ended with overwhelming defeat for Sweden, relegating her to almost minor power status. It left Russia as the new major power in the Baltic Sea and a new important player in European politics. The formal conclusion of the war was marked by the Swedish-Hanoverian and Swedish-Prussian Treaty of Stockholm (1719), the Dano-Swedish Treaty of Frederiksborg (1720), and the Russo-Swedish Treaty of Nystad (1721). In these treaties Sweden ceded all her dominions except for the northern part of Swedish Pomerania, her exemption from the sound dues, and broke all ties with Holstein-Gottorp. Hanover gained Bremen-Verden, Brandenburg-Prussia incorporated the Oder estuary, Russia secured the Baltic provinces, and Denmark her position in Schleswig-Holstein. In Sweden, the absolute monarchy came to an end with Charles XII's death, and the so-called Age of Liberty began.