The church was built in 908, on the remains of another shrine from the 6th century. After the Latin invasion and the restoration of the Byzantine Empire, between 1286 and 1304, Empress Theodora – widow of Emperor Michael VIII Palaiologos – erected another church dedicated to St. John the Baptist, south of the first church.

In 1497 to 1498, shortly after the Fall of Constantinople and during the reign of Sultan Bayezid II, the south church was converted into a mescit (a small mosque).

Later, the edifice burned down in 1633, but was restored in 1636 by Grand Vizier Bayram Pasha, who upgraded the building to a camii (mosque) and converted the north church into a dervish lodge.