Ayasofya was the greatest church in Christendom, and was meant to be. According to Prof. Robert Osterhout, it was built to surpass the gigantic Church of St Polyeuchtos erected by Julia Anitzia, scion of the line of Theodosian emperors.
Being the world's most impressive building, it's no wonder that Mehmet the Conqueror proclaimed it a mosque soon after his conquest of the city from the Byzantines in 1453.
It served as Istanbul's most revered mosque until 1935 when Ataturk, recognizing its world-historical significance, had it proclaimed a museum, as it is now.
Ayasofya is awe-inspiring—one of the first things to see when you're in Istanbul. Luckily, it's right next to Topkapi Palace, the Blue Mosque and the Byzantine Hippodrome, and right across the street from Yerebatan Sarnıçı, the Basilica Cistern.
Ayasofya is one of the stops on Efendi Travel's Old Istanbul Walking Tour, a good way to have a look at the major sights.