Helsinki was founded by the King Gustav Vasa in 1550 as the Swedish town of Helsingfors at the mouth of the River Vantaa. It was established as a trading post to rival the Hansaetic League city of Reval (modern day Tallinn), which at the time dominated trade in the area. At its inception, the residents of several other towns were resettled in Helsingfors by royal decree to ensure its economic viability. After Sweden acquired Reval at the end of the Livonian War in 1582 there was little reason for the Swedish crown to develop Helsingfors as a centre of trade and it remained a small forgotten town for several decades.
In 1643 the town was relocated further south to the Vironniemi headland in an attempt to attract more trade to the city. After Helsingfors was temporarily occupied by Russian forces twice in the first half of the eighteenth century, the Swedish army constructed the sea-fortress of Suomenlinna to protect the city from further attacks. The institutional structure of Finland, including judicial, religious and local government authorities, was largely established during the period of Swedish rule.
Helsingfors began to expand when Finland was annexed by Russia as the autonomous Grand Duchy of Finland in 1809, following the Finnish War. To help reduce the Swedish influence, Tsar Alexander I of Russia had the capital moved from its location at Åbo to Helsingfors in 1812. The Russian tsar commissioned the architects Johan Albrecht Ehrenstrom, a native Finn, and Carl Ludvig Engel, a German, to redesign the city in the Empire style as a modern city along the lines of the Russian capital St. Petersburg.

During the 19th Century, Helsingfors became the economic and cultural centre of Finland. The Finnish language began to dominate the city, as the people who moved to the city were mostly Finnish-speaking. At the beginning of the 20th Century most of the city’s residents spoke Finnish, although a large number of Swedish-speakers remained. The central government structure was, by and large, established during the Russian period, as Finland enjoyed a large degree of autonomy in its domestic policies.
Following independence from Russia in 1917 a civil war broke out and Helsinki fell to the Red Guards along with rest of southern Finland. German troops recaptured Helsinki but the city itself suffered little damage. During the Winter War (1939-1940) and the Continuation War (1941-1944) Soviet bombers attacked the city but again damage was relatively light.
From the 1950s onwards the growth of services industries, together with an increase in industrial employment, led to an extensive population shift from the countryside to Helsinki and the other growing urban centres of southern Finland in what became known as the Great Migration. The city has continued to grow with two suburbs, Espoo (established in 1963) and Vantaa (dating from 1972), today being the country's fourth and fifth largest cities.