The Church of Saints Sergius and Bacchus in Constantinople is dedicated to two Roman soldiers who died as martyrs in the fourth century. The two soldiers were recognized as the patron saints of all soldiers in the Roman armed forces. Their veneration was immensely popular in Syria, and soon spread to other parts of the Roman Empire. The emperor Justinian (r. 527-565) was one of the most ardent devotees. As a youth, he had been condemned to death because he was believed to have plotted against the emperor Anastasios I (r. 491-518), but the twin Saints had, according to a legend, in a dream appeared to the ruler, who had now understood that Justinian was innocent - or that God had greater plans with the man - and had released him.
If this story is true, it comes as no surprise that Justinian dedicated a church to Saints Sergius and Bacchus. The grounds on which he built the sanctuary were not far from the Hormisdas Palace, where the emperor used to live - a bit to the west, to be precise, close to the sea walls. Construction started as soon as Justian ascended to the throne in 527. The architect was Anthemios of Tralles, who was better known as a mathematician and the author of a book on burning mirrors, the Paradoxographia, and would become better known later on as one of the designers of Hagia Sophia.
The Church of Saints Sergius and Bacchus was a complex project, because a second church, which was designed as a basilica (with three straight naves) was very close to it, and in fact shared the entrance (narthex) with the new church. The church was dedicated to the Apostles Peter and Paul, and no traces of it are left. Construction of the Saints Sergius and Bacchus Church took several years, but the project was finished before 536.
The significance of this monument is that its octogonal design was later, on a much larger scale, reused by Anthemios when he (together with Isidore of Miletus) built the Church of Hagia Sophia. An old description of the Saints Sergius and Bacchus Church is offered by Justinian's contempory Procopius (Buildings 1.4.3-7):
Justinian built a shrine to the famous Saints Sergius and Bacchus, and then also another shrine which stood at an angle to this one. These two churches do not face each other, but stand at an angle to one another, being at the same time joined to each other and rivaling each other; and they share the same entrances and are like each other in all respects, even to the open spaces by which they are surrounded; and each of them is found to be neither superior nor inferior to the other either in beauty or in size or in any other respect. Indeed each equally outshines the sun by the gleam of its stones, and each is equally adorned throughout with an abundance of gold and teems with offerings. In just one respect, however, they do differ. For the long axis of one of them is built straight, while in the other church the columns stand for the most part in a semi-circle. But whereas they possess a single colonnaded stoa, called a narthex because of its great length, for each one of their porches, they have their propylaea entirely in common, and they share a single court, and the same doors leading in from the court, and they are alike in that they belong to the Palace.
The dome is very remarkable, because it consists of eight flat and eight concave sections, which rest on eight piers. This is unique, but it might well have become extremely popular. Many churches in this age were very innovative and experimental; the architects were still looking for new forms. Eventually, the dome of the Hagia Sophia was to receive a different design, which became the new standard.
The church was converted into a mosque in the first years of the sixteenth century and is now known as the Küçük Ayasofya, the "Little Hagia Sophia".
Though there is little trace of its Roman history inside since becoming a mosque, there is a Greek inscription that speaks of its origins:
Other sovereigns have honored dead men whose labour was unprofitable, but our sceptred Justinian, fostering piety, honors with a splendid abode the Servant of Christ, Begetter of all things, Sergius; whom not the burning breath of fire, nor the sword, nor any other constraint of torments disturbed, but who endured to be slain for the sake of Christ God, gaining by his blood heaven as his home. May he in all things guard the rule of the sleepless sovereign and increase the power of the God-crowned Theodora whose mind is adorned with piety, whose constant toil lies in unsparing efforts to nourish the destitute.
Since Monophysite refugees were housed in the Hormisdas Palace by Empress Theodora in 536 and 537, it has been proposed that this church was built to serve their needs, as it seems to be indicated in the Greek inscription, but this theory is debated by other scholars.