Emperor Justinian, who quelled the Nika Insurrection in a bloody manner, undertook the construction of a new church at the site of Hagia Sophia, which had burned to the ground on January 13-14, 532. The Byzantine historian Procopius, who lived at the same period and wrote about the life and deeds of the Emperor, states that the new project was taken up on February 23, merely thirty-nine days after the fire. Emperor Justinian assigned two architects, namely Isidorus, the Elder, a Milesian by birth, and Anthemius of Tralles, for his new temple. Anthemius had numerous brothers. One of them was Metrodorus and he was a grammarian of distinction; another one was Olympius, a famous jurist, and Diochorus and Alexandros were doctors of renown of their time. As for :Isidorus, the Elder, he collected the writings of Archimedes, the famous mathematician of the Early Ages; and we owe Isidorus the conservation of these precious writings. Furthermore, both Anthemius and Isidorus, the Elder, have left us certain writings on technical subjects.
Justinian had materials brought for his new temple from all over his empire. He had also brought all the columns of all the temples spread out in Asia Minor. Among these, were the columns of the Artemis Temple at Ephesus. Justinian saved no effort to have stones of various colours brought from far distant quarries in Egypt and Thessaly. According to various old sources, more than ten thousand workers were employed under one hundred foremen, in the construction of Just the church. This construction, rep( carried out in accordance with a the new plan, took five years. The Isid opening of the completed church rec( was on December 27 I 537 I with arcl1 the sacrifice of one hundred oxen, of li sixthousand sheep, six hundred stags, one. thousand pigs, ten thousand hens and ten thousand Dec roosters. Justinian had come to this inauguration andconsecration ceramony, holding hands with the Patriarch, and on seeing the grandeur of the church, he had muttered these words; " My thanks and gratitude to my Lord, for enabling me the means for creating such a glorious temple!" It is also a fact that everything in the new building was not yet completed at the time. For example, the mosaics embellishing the interior were completed at the time of Emperor Justin II (565-578).
Although Hagia Sophia filled one with awe and admiration with its novelty in architecture, the greatness of its dome and the boldness of its creation and the magnificence of its inner decoration, it had not yet settled as regards to static equilibrium. Repairs were undertaken as thegreat dome and the half dome in the east cracked due to earthquakes in August 553 and on December 14, 577. But on May 7, 558, the main dome collapsed. As a result of the debris piling up in the interior, the table for offerings and the Ciborium covering it, as well as the ambon (pulpit) were smashed. Emperor Justinian asked for immeadiate repairs, and entrusted Isidorus, the Younger, the nephew of Isidorus, the Elder, with the reconstruction work. This architect constructed the dome out of lighter materials and raising it about seven meters higher. The re-opening took place on December 23, 562. On the occasion of this second inauguration ceremonies a palaceofficial named Paul, the Silentary , who was also a contemporary Byzantine poet, wrote a long epic poem, describing and praising the greatness, the beauty and the grandeur of Hagia Sophia. This appraisal, which is called Eccphrasis, is an invaluable source for the architectural and decorative characteristics of the Sixth Century Hagia Sophia.
Hagia Sophia has been involved in all incidents throughout the entire Byzantine history; emperors have been crowned and victories have been celebrated here, culprits have saught asylum , in this sanctuary because of the immunity of the Church, and last but not least, foreigners of various nationalities who came to Istanbul paid visits to this great church and architecturalmonument, and came out full of admiration. It is reported that the people entering the service of the church at those times, numbered six hundered. It is also known that all religious pictures and figures were removed from Hagia Sophia, during the period between 726 to 842, known in history as Iconoclasm, which was a form of hostility against pictures, which supposedly was akin to idolatry , and the adherents of this movement were known as iconoclasts. They were literally "image breakers". One of the strong advocates of this movement was Emperor Theophilus (829-842) , who, in order to prove that Hagia Sophia was worthy of his imperial attention, had two wings of a bronze door of a building of antiquity, be installed at the southern entrance to the church. On the surface of these door wings, which are still there today, one can see the monograms implying the name of the Emperor.
Hagia Sophia has suffered a great I fire in 859. But it suffered the greatest damage in the earthquake on January 8, 869. One of its half domes at the West has fallen down, Emperor Basil I (867 -886) had immeadiately ordered the necessary repairs to be made. During these years, Orso Partetsipatio, the Doge of Venice, made a present to the Byzantine emperor, of a bell to be hung at Hagia Sophia. An earthquake taking place on the eve of 25-26 October, 989, caused the demolition of the great dome and the many parts of the edifice.at that time Basil II (976-1025) was in reign and he restored the church into its former status through a six-years-period of repairs, carried out by an architect called Tridat. The holy building was re-opened for church services on May 13, 994. The long duration of the repairs, indicate the importance and magnititude of the damage caused by the earthquake.
As Hagia Sophia was the greatest religious center of the Byzantine world, a great many of the ceramonies in which the Emperor and the Patriarch participated, took place here. Emperor Constantine VII Porphyrogenitus (913-919) has given all the details of these ceramonies in the Book of Ceramonies he wrote; and his book constitutes an important source of information on the Tenth Century .The big religious meetings in Hagia Sophia were being held in the southern gallery of the upper floor. The resolutions made at the meeting held in 1166, were hung on the wall. Today we can see only their copies.
The Fourth Crusade, headed for Jerusalem, changed its course in 1203 and came to Istanbul. Emperor Alexius IV, who was indepted to them, was forced to give the Latins some of the precious articles of Hagia Sophia. When the Latins of the Crusading Army captured the city in 1204, they looted and ransanked the city, Hagia Sophia and the precious materials in the other churches, as well as other pieces they laid their hands on or things they considered to be of value. Besides the plundering of the churches, some regretable and ugly incidents also happened in Hagia Sophia during the first few days of confusion. The offering of the Virgin Mary was torn into pieces, wine was drunk from chalices used in religous ceramonies, mounting animals were introduced right into the interior of the church to be loaded with the looted articles. If one has to believe the Thirteenth Century Byzantine historian Nicetas Acominatus, a prostitute mounted the pulpit, sang and danced there. During these plunders, many holy relics such as "a portion of the True Cross", a piece of stone from the grave of Jesus, Virgin Mary's milk, the shroud of Jesus, bones of many saints that were all preserved in valuable cases were all taken out of Saint Sophia and sent to the churches in the West. Today, all these relics that were sent in 1204, are being displayed in various museums in Europe.
After the cease of the initial insolences, Hagia Sophia was in the possession of the Venetians. Though there were constant arguments due to their not yielding the administration of Hagia Sophia to the other Catholics, five emperors were crowned here during the Latin invasion, which continued up to 1261. The stone slab with the inscription Enrico Dandolo, seen on the floor of the upper storey of Hagia Sophia, is believed to be the grave of the Venetian Doge, who made many efforts for the seizure of Istanbul from the Byzantines and who died here. Another rumour is to the effect that this was engraved during the restoration in the former century ( 1847 -1849) , in an effort to makea symbolical burial site for keeping alive the memory of Dandolo. When the Byzantines recaptured the city and revived the empire in 1261, Hagia Sophia was in a deprorably worn out state. The four supporting buttresses in the west were very likely built at that time. In 1317 , Emperor Andronicus II (1282- 1328) had supporting buttresses built in the eastern and nothern parts of the building, in order to remedy the dangerous position of those parts. The violent earthq.uake in October 1344, caused some new cracks at Hagia Sophia, but collapses took place on May 19, 1346, two years later. This major earthquake led to the collapse of the eastern arch together with the eastern part of the dome, as well as damages in other sections. As the Byzantine Empire was in no financial state to meet the expenses repairs, the church was left closed for some time. The repairs, however, were undertaken in 1354, by means of levying special taxes and collecting donations. It is known that the repair work was carried out, by two Latin architects, namely Astras and Peralta.
The trevelers visiting Istanbul in the beginning of the Fifteenth Century narrate that the vicinity of Hagia Sophia was full of ruins, and the church itself was in a wretched and neglected status, with many of its doors falling down and lying on the ground. When the Turks conquered Istanbul in 1453, Hagia Sophia was in a desolate and devastated situation.