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.
History of Stockholm
Because Stockholm had a city wall, it was exempted from the tax paid by other Swedish cities. During the reign of Gustav Vasa the city's fortifications were reinforced and in the Stockholm Archipelago, Vaxholm was created to guard the inlet from the Baltic. While the medieval structure of Stockholm remained mostly unaltered during the 16th century, the city's social and economic importance grew to the extent that no king could permit the city to determine its own faith – the most important export item being bar iron and the most important destination Lübeck. During the reign of Vasa's sons, trade led many Swedes to settle in the city, but the trade and the capital needed to control it was largely in the hands of the king and German merchants from Lübeck and Danzig. Throughout the era, Sweden could hardly claim the level of government and bureaucracy requisite to a capital in the modern sense, but Stockholm was the kingdom's strongest bastion and the king's main residence. As Eric XIV's pretensions were on par with those of Renaissance princes on the continent, he afforded himself the largest court his finances could possibly support, and the royal castle was thus the biggest employer in the city.