Storkyrkan was first mentioned in written sources in 1279. The consecration of a church is furthermore attested in 1306, making it the oldest church in Stockholm. The earliest history of the church is thus somewhat unclear: Stockholm was founded in the middle of the 13th century and it has been considered unlikely that the city would not have a functioning church until 1306. Tradition also holds that Birger Jarl founded the church. It is therefore possible that the church inaugurated in 1306 was preceded by another church, or that it was under construction for a long time, or perhaps re-dedicated in 1306. Regardless, the oldest parts of the current building probably belong to the church which was inaugurated in 1306. During the entire Middle Ages, the main patron saint of the church was Saint Nicholas. Several churches in the Baltic region from the 13th century are dedicated to Saint Nicholas, especially in cities where the Hanseatic League had a presence, as was the case in Stockholm. The church was also dedicated to Saint Mary and Saint Eric. The church remained the only parish church of Stockholm, serving the entire city, until the 1590s. In general, the medieval history of the church building is complex and difficult to determine in detail. There are few written sources, and a lack of ornaments has made it difficult to draw any conclusions about the age of the different parts on stylistic grounds.