In the 18th century, Sweden did not have enough resources to maintain its territories outside Scandinavia, and most of them were lost, culminating with the loss in 1809 of eastern Sweden to Russia, which became the highly autonomous Grand Principality of Finland in Imperial Russia.
In interest of re-establishing Swedish dominance in the Baltic Sea, Sweden allied itself against its traditional ally and benefactor, France, in the Napoleonic Wars. However, in 1810, a French Marshal, Jean-Baptiste Bernadotte, was chosen as heir presumptive to the decrepit Charles XIII; in 1818, he established the House of Bernadotte, taking the regnal name of Charles XIV. Sweden’s role in the Battle of Leipzig gave it the authority to force Denmark–Norway, an ally of France, to cede Norway to the King of Sweden on 14 January 1814 in exchange for the northern German provinces, at the Treaty of Kiel. The Norwegian attempts to keep their status as a sovereign state were rejected by the Swedish king, Charles XIII. He launched a military campaign against Norway on 27 July 1814, ending in the Convention of Moss, which forced Norway into a personal union with Sweden under the Swedish crown, which lasted until 1905. The 1814 campaign was the last time Sweden was at war.
Despite the slow rate of industrialization into the 19th century, many important changes were taking place in the agrarian economy due to constant innovations and a rapid population growth. These innovations included government-sponsored programs of enclosure, aggressive exploitation of agricultural lands, and the introduction of new crops such as the potato. Because the Swedish peasantry had never been enserfed as elsewhere in Europe, the Swedish farming culture began to take on a critical role in Swedish politics, which has continued through modern times with modern Agrarian party (now called the Centre Party). Between 1870 and 1914, Sweden began developing the industrialized economy that exists today.
World War I and World War II:
Sweden was officially neutral during World War I, although, under German pressure, they did take steps which were detrimental to the Allied powers including mining the Øresund channel, thus closing it to Allied shipping, and allowing the Germans to use Swedish facilities and the Swedish cipher to transmit secret messages to their overseas embassies. Sweden also allowed volunteers to fight for the White Guards alongside the Germans against the Red Guards and Russians in the Finnish Civil War, and briefly occupied the Åland Islands in co-operation with Germany.