Prehistory and origin of Stockholm
According to the Chronicle of Eric, written in the 1320s, Stockholm was founded by Birger Jarl around 1250 as a lock to the Lake Mälaren region ("laas fore then sio", "lock before that lake") in order to prevent pirates from reaching the seven cities and nineteen parishes around it. Another medieval source ("Visbyannalerna"), however, claims the city was founded in 1187 following a pagan pillaged the city of Sigtuna, and as there was an "Earl" named Birger around at that time too, the disputed origin of the city are likely to remain obscure and some historians choose a diplomatic interpretation saying there was some sort of fortification around by the mouth of lake Mälaren when the city was founded during the second half of the 13th century. As Snorri mentions no city in his account but some sort of fortification called a "kastali" (in various manuscripts curiously said to be located east and west of "Stocksund"), it has generally been assumed this fortification eventually developed into the castle Tre Kronor located where still is the Stockholm Palace.
Stockholm
By the second half of the 19th century, Stockholm had regained its leading economic role. New industries emerged and Stockholm was transformed into an important trade and service centre as well as a key gateway point within Sweden. The population also grew dramatically during this time, mainly through immigration. At the end of the 19th century, less than 40% of the residents were Stockholm-born. Settlement began to expand outside the city limits. The 19th century saw the establishment of a number of scientific institutes, including the Karolinska Institutet. The General Art and Industrial Exposition was held in 1897. From 1887 to 1953 the Old Stockholm telephone tower was a landmark; originally built to link phone lines, it became redundant after these were buried, and it was latterly used for advertising.
Stockholm became a modern, technologically advanced, and ethnically diverse city in the latter half of the 20th century. Many historical buildings were torn down during the modernist era, including substantial parts of the historical district of Klara, and replaced with modern architecture. However, in many other parts of Stockholm (such as in Gamla stan, Södermalm, Östermalm, Kungsholmen and Vasastan), many "old" buildings, blocks and streets built before the modernism and functionalism movements took off in Sweden (around 1930–35) survived this era of demolition. Throughout the century, many industries shifted away from industrial activities into more high-tech and service industry areas.