Hagia Sophia was built between 532 and 537 by the Byzantine Emperor Justinian I. By that time, Constantinople/Istanbul had been the capital of the Roman Empire for about 200 years. (Constantinople became Istanbul only in the 1930s.) Hagia Sopia was the largest church in the world for nearly 1000 years (the Sevilla Cathedral surpassed it.)
But the most amazing feature of the Hagia Sophia was its masonary dome. It was the largest masonery dome in the world for nearly a millenium.
Hagia Sopia's history is also fascinating. It was a Christian church until Constantiople was sacked by the (rather misdirected) Fourth Crusade, when it briefly became a Roman Catholic church. When retaken by the Byzantines, it became an Orthodox church, and then, in 1453 a mosque after the Fall of Constantinople. Hagia Sophia remained a mosque until 1935 when it was secularized and made into a museum after Turkey became a republic.
It's worth saying that Hagia Sophia is not another way of saying St. Sophia. It's a transliteration of the Greek for Holy Wisdom.