In 908, the Byzantine admiral Constantine Lips[1] inaugurated a nunnery in the presence of the Emperor Leo VI the Wise (r.
[2] The nunnery was dedicated to the Virgin Theotokos Panachrantos ("Immaculate Mother of God") in a place called "Merdosangaris" (Greek: Μερδοσαγγάρης),[3] in the valley of the Lycus (the river of Constantinople).
Several exponents of the imperial dynasty of the Palaiologos were buried there besides Theodora: her son Constantine, Empress Irene of Montferrat and her husband Emperor Andronikos II (r.
The custom of burying members of the imperial family in the complex continued in the 15th century with Anna, first wife of Emperor John VIII Palaiologos (r. 1425–1448), in 1417.
[10] In 1497–1498, shortly after the Fall of Constantinople and during the reign of Sultan Beyazid II (1481–1512), the south church was converted into a mescit (a small mosque) by the Ottoman dignitary Fenarizade Alâeddin Ali ben Yusuf Effendi, Qadi 'asker[12] of Rumeli, and nephew of Molla Şemseddin Fenari,[2] whose family belonged to the religious class of the ulema.
The edifice burned down in 1633, was restored in 1636 by Grand Vizier Bayram Pasha, who upgraded the building to cami ("mosque") and converted the north church into a tekke (a dervish lodge).
In this occasion the columns of the north church were substituted with piers, the two domes were renovated, and the mosaic decoration was removed.
The masonry of the northern church was erected by alternating courses of bricks and small rough stone blocks.
During the mass the believers were confined in the deambulatoria, which were shallow and dark, and could barely see what happened in the central part of the church.
The masonry is composed of alternated courses of bricks and stone, typical of late Byzantine architecture in Constantinople.
The bricks are arranged to form patterns like arches, hooks, Greek frets, sun crosses, swastikas and fans.