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.
Gamla stan
The name Stockholm originally referred to Gamla Stan only, but as the city expanded, the name now also refers several suburban areas and the metro region. The name Stockholm means "log island" in Swedish. The previous capital of Sweden was located in Sigtuna. A thousand years ago Sigtuna had problems with armed gangs attacking the city. The situation became untenable and there was a need to find a new location for the capital city of Sweden. According to legend the leaders in Sigtuna then took a log of wood, cut out all the wood inside, filled it with gold, and let it float on the water. The log was floating on the water for several days and eventually hit land on the island where Gamla Stan today is located. The island was named Stockholm or log island, meaning the place where the log had hit ground. This is where they decided to found the new capital of Sweden. The island of Stockholm had the advantage that it was an island, easy to defend from armed gangs that could be thought to want to attack the city. It also had the advantage from a trade point of view, that it was situated just at the inlet of Lake Mälaren, a big lake very important to contemporary trade, from the Baltic. A sculpture symbolizing the old log is today found at Stadshuset, the Stockholm City Hall.