After the proclamation of Christianity as the official state religion, by Emperor Constantine I., known as the Great, (324-337 A.D.), construction of big churches were undertaken everywhere in Byzantium. Constantine, the Great was claimed, not justly perhaps, to be the founder of many churches, because of his manifestation of such tolerance. Socrates (380-440) , the chronicler of the church history of the period, states that the first building of Hagia Sophia (or sometimes referred to as Saint Sophia) was erected by Constantine the Great.
Hagia Sophia, which is one of the outstanding monuments in the history of art in our planet, had been called a "Megalo Ecclesia" (meaning a colossal church ) at its first construction. This great monument has, however, been called as Sophia since the Fifth Century. This architectural marvel was not, however, dedicated to a Saint as one may think, but has been dedicated to the Holy Wisdom (Theia Sophia), which is the second element of the Christian Trinity .The populace of Byzantium continued for a long time to call this church as "Megalo Ecclesia " .After the conquest of Byzantium in 1453, the name Hagia Sophia has survived to modern times.
The first church was inaugurated with pomp and circumstance on February 15, 360 A.D. The building was like its contemporary religious edifices, was built with a wooden roof on an oblong basilica. Saint John Chrysostom, the Patriarch of Constantinople (Istanbul) , was for a long time in constant struggle with the Empress Eudoxia, wife of Emperor Arcadius (395-408) .As a result of a dispute over a silver- plated statue of the empress to be erected outside of, but in the close vicinity of the church, the Patriarch was sent to exile on June 20, 404, and during the riots that immediately followed his exile, the church was partly burned down. Its restoration was completed in the reign of Emperor Theodosius II ( 408-450) .After a long period of repairs, the church was inaugurated again on October 10, 415. This newly restored Hagia Sophia was to stand intact for slightly more than a century. At the time of Emperor Justinian, the Great (527-565), just before the realization of the Sixth Century, a strong feud started in Byzantium between the Blues and the Greens.
These were, at first, sports clubs so- named as they were groups participating at the horse races in the Hippodrome, and bearing those colours respectively. But later on, these groups assumed political identities, and began to turn into instruments reflecting the different tendencies of the people. As time went by, the Blues assumed the representation of Orthodoxism and the big land owners, while the Greens represented the Monophysi- tes, tradesmen and artisans. The ranks in the political, social and religious strata of the society thus became clearly distinct in the conflict between the Blues and the Greens. In 532 A.D., the Blues and the i iGreens joined forces in rebelling against emperor Justinian, the Great. The riots breaking out first in the Hippodrome, and known in history as "the Nika riots" (Nika meaning "to conquer" ) , soon spread out to the entire city .The fire breaking out during the ensuing tumult, caused Hagia Sophia to burn down. The emperor, who had accepted defeat and was about to flee, saved his crown thanks to his wife, the empress Theodora, who sent out Generals Narces and Balisarius to suppress the rebellion. The Palace Guards, attacking the rebels, restored the law and order by putting ten thousands of rebels to the sword.
Despite the suppression of the rebellion on January 13, 532, unfortunately Hagia Sophia was being consumed in flames for the second time. During the excavations carried out by A.M. Schneider in 1935 in the western courtyard of Hagia Sophia, a lot of big marble slabs were unearthed. The slabs were ornamented with lambs in relief, representing the twelve apostles. It was thus discovered that these slabs were fragments of an entrance of monumental dimensions. These are apparently the remains of the entrance front of the second Hagia Sophia, built by Emperor Theodosius 11, in the form of a basilica. This second Hagia Sophia, the remains of which we see today, was burned down during the Nika riots. We find out from Procopius, the Byzantine historian of the period, that as soon as the rioting mob were put to the sword, Emperor Justinian took steps to build an edifice that would be entirely different from its earlier models, but would be a more majestic and gigantic temple ever built up to that time.