The Great Northern War (1700–1721) was a conflict in which a coalition led by the Tsardom of Russia successfully contested the supremacy of the Swedish Empire in Northern, Central and Eastern Europe. The initial leaders of the anti-Swedish alliance were Peter I of Russia, Frederick IV of Denmark–Norway and Augustus II the Strong of Saxony–Poland–Lithuania. Frederick IV and Augustus II were defeated by Sweden, under Charles XII, and forced out of the alliance in 1700 and 1706 respectively, but rejoined it in 1709 after the defeat of Charles XII at the Battle of Poltava. George I of Great Britain and the Electorate of Hanover joined the coalition in 1714 for Hanover and in 1717 for Britain, and Frederick William I of Brandenburg-Prussia joined it in 1715.
Charles XII led the Swedish army. Swedish allies included Holstein-Gottorp, several Polish magnates under Stanislaus I Leszczyński (1704–1710) and Cossacks under the Ukrainian Hetman Ivan Mazepa (1708–1710). The Ottoman Empire temporarily hosted Charles XII of Sweden and intervened against Peter I.
The war began when an alliance of Denmark–Norway, Saxony and Russia, sensing an opportunity as Sweden was ruled by the young Charles XII, declared war on the Swedish Empire and launched a threefold attack on Swedish Holstein-Gottorp, Swedish Livonia, and Swedish Ingria. Sweden parried the Danish and Russian attacks at Travendal (August 1700) and Narva (November 1700) respectively, and in a counter-offensive pushed Augustus II's forces through the Polish–Lithuanian Commonwealth to Saxony, dethroning Augustus on the way (September 1706) and forcing him to acknowledge defeat in the Treaty of Altranstädt (October 1706). The treaty also secured the extradition and execution of Johann Reinhold Patkul, architect of the alliance seven years earlier. Meanwhile, the forces of Peter I had recovered from defeat at Narva and gained ground in Sweden's Baltic provinces, where they cemented Russian access to the Baltic Sea by founding Saint Petersburg in 1703. Charles XII moved from Saxony into Russia to confront Peter, but the campaign ended in 1709 with the destruction of the main Swedish army at the decisive Battle of Poltava (in present-day Ukraine) and Charles' exile in the Ottoman town of Bender. The Ottoman Empire defeated the Russian-Moldavian army in the Pruth River Campaign, but that peace treaty was in the end without great consequence to Russia's position.
After Poltava, the anti-Swedish coalition revived and subsequently Hanover and Prussia joined it. The remaining Swedish forces in plague-stricken areas south and east of the Baltic Sea were evicted, with the last city, Riga, falling in 1710. The coalition members partitioned most of the Swedish dominions among themselves, destroying the Swedish dominium maris baltici. Sweden proper was invaded from the west by Denmark–Norway and from the east by Russia, which had occupied Finland by 1714. Sweden defeated the Danish invaders at the Battle of Helsingborg. Charles XII opened up a Norwegian front but was killed in the Siege of Fredriksten in 1718.
The war ended with the defeat of Sweden, leaving Russia as the new dominant power in the Baltic region and as a new major force in European politics. The Western powers, Great Britain and France, became caught up in the separate War of the Spanish Succession (1701–1714), which broke out over the Bourbon Philip of Anjou's succession to the Spanish throne and a possible joining of France and Spain. The formal conclusion of the Great Northern War came with the Swedish-Hanoverian and Swedish-Prussian Treaties of Stockholm (1719), the Dano-Swedish Treaty of Frederiksborg (1720), and the Russo-Swedish Treaty of Nystad (1721). By these treaties Sweden ceded its exemption from the Sound Dues and lost the Baltic provinces and the southern part of Swedish Pomerania. The peace treaties also ended its alliance with Holstein-Gottorp. Hanover gained Bremen-Verden, Brandenburg-Prussia incorporated the Oder estuary (Stettin Lagoons), Russia secured the Baltic Provinces, and Denmark strengthened its position in Schleswig-Holstein. In Sweden, the absolute monarchy had come to an end with the death of Charles XII, and Sweden's Age of Liberty began.