The Little Hagia Sophia mosque is a former Greek Orthodox church dedicated to Saints Sergius and Bacchus in Constantinople (modern Istanbul). It is nonetheless one of the most important early Byzantine buildings in Istanbul. The construction of this church, between 527 and 536 AD, was one of the first acts of the reign of Justinian I.
After the Ottoman conquest of Constantinople in 1453, the church remained untouched until the reign of Bayezid II. Then between 1506 and 1513 it was transformed into a mosque. At that time the portico and madrasah were added to the church.
In 1740 the Grand Vizier Hacı Ahmet Paşa restored the mosque and built the Şadırvan (fountain). Damage caused by the earthquakes of 1648 and 1763 was repaired in 1831 under the reign of Sultan Mahmud II. In 1762 the minaret was first built. It was demolished in 1940 and built again in 1956.
References:The Walls of Constantinople are a series of defensive stone walls that have surrounded and protected the city of Constantinople (today Istanbul) since its founding as the new capital of the Roman Empire by Constantine the Great. With numerous additions and modifications during their history, they were the last great fortification system of antiquity, and one of the most complex and elaborate systems ever built. They were also the largest and strongest fortification in both the ancient and medieval world.
Initially built by Constantine the Great, the walls surrounded the new city on all sides, protecting it against attack from both sea and land. As the city grew, the famous double line of the Theodosian Walls was built in the 5th century. Although the other sections of the walls were less elaborate, they were, when well-manned, almost impregnable for any medieval besieger.