In 1167, Bishop Absalon of Roskilde had a castle built at a commercial centre called Havn. The Bishop had been given the land by King Valdemar I.
In the beginning of the 13th century, the merchants became more and more interested in Havn. A town was founded in the German style, with a square, a church and a Town Hall at its centre. The name was changed into Copenhagen and in 1254 the town was granted a town charter. The trade and the herring fishery in the southern parts of the Baltic Sea made Copenhagen grow rapidly in the 13th and 14th centuries. More churches were built as well as a strong city wall. In 1368, the town was conquered by the Hanseatic League, and its fortifications were torn down.
In 1416, the Roskilde bishops had to give the town to the King. The castle was rebuilt as a royal residence and the town became the capital of the Danish kingdom. During the last century of the Middle Ages, the town grew rapidly. Copenhagen became a model to other Danish towns. At the beginning of the 17th century, King Christian IV ordered new parts of the city to be built. During this period, the Trinity Church with Runde Tårn was built.
Under Christiansborg, where "Folketinget" ( the Danish parliament ) resides, are the ruins of Absalon Castle and the first castle of Copenhagen. Most of the medieval buildings are gone, due to a number of fires in the town. On the other hand, numerous 17th-century buildings are still standing.