The church of St. Sofia is one of the largest medieval churches on this territory. For a long time, it was the cathedral church ("Great Church") of the Ohrid Archiepiscopate whose ecclesiastical authority covered the territories up to the river Danube to the north, the Albanian coast to the west, and the Bay of Thessalonica to the east. The church was probably used as a cathedral way back in the past, in the period of the Car Samuel who, in the late X century, moved his throne from Prespa to Ohrid. The other assumption is that there used to be another church on the same site during the reign of the Macedonian Czar Samuel and that later on this church was ruined for unknown reasons. The date of the construction of that church is uncertain because there are no inscriptions that help reveal it. It is also mentioned that today's church was either built or restored during the period of the Archbishop Leo who was on the throne of the Church in the period between 1035-1056. His esteemed ecclesiastical principle became a donor of the painting decorations in the church of St. Sofia. The original church had only one main dome. In the XIV century, an opulent external narthex was constructed. Its original shape was a three-naval basilica with a transept, a dome, and galleries on the side naves. It had a parvis and separate chapels above the northern and southern altar sections even in XI century. Almost three centuries later, during the period of the Archbishop Gregorius, a new parvis was built. It represents the climax of the Macedonian XIV-century culture. The concept of the extended parvis was horizontal, with a portico on the ground, and galleries on the first floor. Above the Gregorious Gallery, on the northern and southern sides, there were separate sections with towers. With the arrival of the Turks, the church St. Sofia was converted into a mosque. They "took care" to reshape the church almost entirely so that it could serve the Muslim religion. The frescoes were whitewashed, the ornamented plates from the iconostasis were used for constructing the internal staircase, and a minaret was built above the northwest dome. These undertakings distorted the structure of the entire church. In the period from 1950 to 1957 extensive conservatory and restoration activities were performed. The frescoes were cleaned and conserved, and also some reconstruction work was done. The fresco paintings in the church are amongst the highest achievements in medieval painting in Macedonia and even wider. At that time Ohrid was under the direct authority of the Constantinople Patriarchate, so these are the most important preserved works of Byzantine monumental painting. The donor of the fresco paintings, one of the most learned men of the time, Archbishop Leo, directly influenced the selection of the compositions painted in the XI century.