Towards the middle of the ninth century, Princess Thekla, eldest daughter of Emperor Theophilus enlarged a small oratory, dedicated to her patron saint and namesake, lying east of the Church of Theotokos of the Blachernae. In 1059 on this site, Emperor Isaac I Komnenos built a larger church, as thanks for surviving a hunting accident. The church was famous for its beauty, and Anna Comnena writes that her mother, Anna Dalassena, used to go often and pray there. After the Ottoman conquest of Constantinople, the building was heavily damaged during the earthquake of 1509, which destroyed the dome. Shortly after that, "Kapicibaşi" (and later Grand Vizier) Koca Mustafa Pasha, executed in 1512, repaired the damages and converted the church into a mosque. Up to the end of nineteenth century, a Hamam, placed south of the building, also belonged to the mosque's foundation. In 1692, Şatir Hasan Ağa built a fountain in front of the mosque. In 1729, during the great Fire of Balat, the building was heavily damaged and repaired some years later. It was damaged again during the 1894 Istanbul earthquake, which destroyed the minaret, and reopened for worship in 1906. A last restoration occurred in 1922. In that occasion, a marble christening font was brought to the Istanbul Archaeology Museum. Inside the south apse of the building there is the türbe (tomb) attributed to Hazreti Cabir (Jabir) Ibn Abdallah-ül-Ensamı, one of the companions of Eyüp, fallen nearby in 678 during the first Arab siege of Constantinople.