The church of Ayasofya, now used as a museum, was built during the reign of Manuel Comnenos I, king of the Empire of Trabzon (1238-1263). The bell tower to the west of the church was dated to 1427. The chapel with three apses, the remains of which are to the north of the church, must belong to an earlier period. In the 15th century the church was turned into a mosque.