Two earlier churches occupied the spot where Hagia Sophia stands, both of which were destroyed within one hundred years of their construction. But the third building, built by the Emperor Justinian in the sixth century CE, was a masterpiece built to last, and for almost one thousand years it stood as the largest cathedral in all Christendom, East and West.
Following the Ottoman conquest of Constantinople in 1453, Sultan Mehmet swiftly converted the church into a mosque - "Ayasofya Camii" - but because he revered the building and its impressive history, he kept the structure and its contents virtually unchanged. The four minarets around its perimeter were added at various times in the century after conquest.
These days, Hagia Sophia is not an official place of worship - rather, it is a museum. So if you visit, keep this in mind: the voice you hear echoing between your ears might just be the guided audio tour.