The history of Kastoria opens in the 6th century when the emperor Justinian I decided to transfer the population of the nearby city of Diokletianoupolis, destroyed in barbarian raids, to a secure peninsula on the shore of Lake Kastoria.
Kastoria city first appears in history during a period of Bulgarian incursions which were successfully repulsed in 1018. It was captured by the Normans in 1081 and liberated soon afterwards by the emperor Alexios I Komnenos.
Armed forces of Bulgarians and from the neighbouring state of Epirus and the empire of Nicaea were active in Kastoria and its vicinity during the 13th century. In the next century the city was occupied first by the Serbs, then by the Albanians and finally, in 1386, by the Turks.