Swedish political power had been centred around Mälaren lake for centuries, but it was forced to move to the lake's outlet when the rising land made navigation for large boats between the sea and lake impractical. Sweden's most important chieftain in the mid-13th century, Birger Jarl, ordered the construction of a fort on one of the strategically placed islets, where the fresh water entered the sea, and traffic on the waterways was controlled using timber stocks arranged as a fence, or boom. Stockholm, roughly meaning 'tree-trunk islet', may well be named after this boom.
The oldest record of the city consists of two letters dating from 1252. Within a hundred years, Stockholm was the largest city in Sweden, dominated by an impregnable castle (which was never taken by force) and surrounded by a defensive wall. During the period of the Kalmar Union, the king's governor directed affairs from the castle. The city was periodically ravaged by fire until timber buildings with turf roofs were replaced with brick structures. By the late 15th century, the population was around 6000 and Stockholm had become a significant commercial centre. Shipping copper and iron to continental Europe was a lucrative trade that was dominated by German merchants.
In 1471, the Danish king, Christian I, besieged Stockholm while attempting to quell the rebellious Sten Sture, but his 5000-strong army was routed by the Swedes just outside the city walls at the Battle of Brunkeberg (the fighting took place between what is now Vasagatan, Kungsgatan and Sergels Torg). Even after the Danish retreat to Copenhagen, trouble between unionists and separatists continued. Things escalated in 1520 when city burghers, bishops and nobility agreed to meet Danish King Christian II in Stockholm, where he arrested them all at a banquet. After a quick trial, the Swedes were found guilty of burning down the archbishop's castle near Sigtuna, and 82 men were beheaded the following day at Stortorget (the main square by the castle). This ghastly event became known as the Stockholm Bloodbath after heavy rain caused rivers of blood from the bodies to pour down steep alleys descending from the square.
A major rebellion followed and Gustav Vasa finally entered the city in 1523, after a two-year siege. The new king ruled the city with a heavy hand - the role of commerce dwindled and the church was extinguished entirely as royal power grew and the city revolved increasingly around the court. Gustav's son Erik XIV (and later kings) racked up taxation on the burghers to fund wars, but some did well from arms manufacturing and the city's importance as a military headquarters increased. At the end of the 16th century Stockholm's population was 9000, but this expanded in the following century to 60, 000, as the Swedish empire reached its greatest extent.
In the 17th century, town planners laid out a street grid beyond the medieval city centre, and Stockholm was proclaimed the capital of Sweden in 1634. Famine wiped out 100, 000 people across Sweden during the harsh winter of 1696, and starving hordes descended on the capital. The following year, the original royal castle (Tre Kronor) burned down. In 1711 plague arrived, and the death rate soared to 1200 per day from a population of only 50, 000. After the death of King Karl XII, the country, unsurprisingly, stagnated.
In the 18th century, Swedish science and arts blossomed, allowing the creation of institutions and fine buildings. Another period of stagnation followed the assassination of King Gustav III; promised 19th-century reforms never arrived, and bloody street riots were common.
From the 1860s, further town planning created many of the wide avenues and apartment blocks still seen today. The city rapidly industrialised and expanded. In 1912, the Olympic Games were held in Stockholm and by 1915 it was home to 364, 000 people.
The next major transformation of the city started in the 1960s, when large 'new towns' sprung up around the outskirts, and extensive 'slum' areas were flattened to make way for concrete office blocks, motorways and other modern developments. The financial and construction boom of the 1980s helped make the city a very expensive place. When that bubble burst due to the 1990s recession, the devalued krona actually helped Stockholm: Swedish tourism grew, and foreign tourists arrived in ever-increasing numbers. The relative easing of licensing restrictions on bars and restaurants, such as hours during which alcohol could be sold, the type of alcohol that was sold and the age of clientele, caused a huge increase in the number of licensed premises and helped create the lively Stockholm you see today.