On 23 February 532, only a few weeks after the destruction of the second basilica, Emperor Justinian I decided to build a third and entirely different basilica, larger and more majestic than its predecessors, built by Constantius II and Theodosius II.
Justinian chose physicist Isidore of Miletus and mathematician Anthemius of Tralles as architects; Anthemius, however, died within the first year of the endeavor. The construction is described in the Byzantine historian Procopius’ On Buildings (Peri ktismatōn, Latin: De aedificiis). Columns and other marbles were brought from all over the empire, throughout the Mediterranean. Even though they were made specifically for Hagia Sophia, the columns show variations in size. More than ten thousand people were employed. This new church was contemporaneously recognized as a major work of architecture. The theories of Heron of Alexandria may have been utilized to address the challenges presented by building such an expansive dome over so large a space. The emperor, together with the Patriarch Menas, inaugurated the new basilica on 27 December 537 – 5 years and 10 months after construction start – with much pomp. The mosaics inside the church were, however, only completed under the reign of Emperor Justin II (565–578).
Hagia Sophia was the seat of the Orthodox patriarch of Constantinople and a principal setting for Byzantine imperial ceremonies, such as coronations. Like other churches throughout Christendom, the basilica offered sanctuary from persecution to outlaws.
Earthquakes in August 553 and on December 557 caused cracks in the main dome and eastern half-dome. The main dome collapsed completely during a subsequent earthquake on 7 May 558, destroying the ambon, altar, and ciborium. The collapse was due mainly to the unfeasibly high bearing load and to the enormous shear load of the dome, which was too flat. The emperor ordered an immediate restoration. He entrusted it to Isidorus the Younger, nephew of Isidore of Miletus, who used lighter materials and elevated the dome giving the building its current interior height of 55.6 meters. Moreover, Isidorus changed the dome type, erecting a ribbed dome with pendentives, whose diameter lay between 32.7 and 33.5 m. Under Justinian’s orders, eight Corinthian columns were disassembled from Baalbek, Lebanon, and shipped to Constantinople around 560. This reconstruction, giving the church its present 6th-century form, was completed in 562.