The church of Hagia Sophia was built in the city of
, the capital of the Byzantine Empire. Although on the church's site there had been smaller shrines dated to the 4th and 5th centuries AD, it was during the reign of Emperor
that the edifice was built.
After a revolt on circus factions in the capital, the Emperor, seeing the hitherto small and relatively undistinguished Church of Hagia Sophia in charred ruins, decided to renovate the building and make it the single most important church in the world. To accomplish that, he ordered the architects
of Tralleis and Isidore of
to design Hagia Sophia.
After years of laborious work, Hagia Sophia was consecrated in 537. Upon seeing the church, the jubilant Emperor exclaimed: "I have triumphed over you,
", a reference to the Temple of God mentioned in the
.
Some damage to the church was done after an
in 558, after which the Emperor immediately ordered the restoration of Hagia Sophia. To further add stability to the new elements, eight columns were transported from
, now called Baalbek, in Lebanon.
In the 7th century, during the reign of
, due to the dire need of funds, the golden liturgical vessels were melted down to mint coin. In 626, when the imperial capital itself was under
by the Avars, the population found refuge in their church.
Perhaps the most fitting way to close this would be a reference to how another important person of the Middle Ages perceived Hagia Sophia. It is said that when the Prince of
, Volodymyr Svyatoslavych, sent envoys to various states professing various religions, his ambassadors, upon arriving in the
, as they called Byzantium, and being led inside Hagia Sophia, were "led into a place where they serve their God, and we did not know where we were, in heaven or on earth", as the
attests, thus inspiring the Prince to convert to Orthodoxy.