It was built in the 10th or 11th century, during Byzantine times as a church, and received its present name and function after the Ottoman conquest of the city in 1461. The north entrance was built by the Ottomans. In 1975 a large restoration took place and the ceiling was covered with concrete.