Before the first Hagia Sophia was built there was a pagan temple on the same spot and Constantine The Great planned to build the first church there .Same place different door!
The first Hagia Sophia was built by the Emperor Constantius, the son of Constantin the great in 360 AD and it was a basilica planned church with a timbered roof. When the emperor Arcadius exiled the patriarch of Constantinople, JohnChrysostom for his open criticism of the empress Eudoxia, people got angry and burned down the first church in 404 AD.
11 years later emperor Theodosius II built second Hagia Sophia at the same site. The second church was again basilica planned and again had a timbered roof. And it lasted a little bit longer than the first one but its destiny was almost the same with the first one. People were having some fun with chariots in Hippodrome and two factions; Blues and Greens, had a fight and it turned into a big riot; NIKERIOTS. Since the rioters shouted ''NIKE, NIKE, NIKE’’ repeatedly during the riot, it is known as NIKE RIOTS or NIKA RIOTS. Theyset fire too many public buildings and tried to depose the emperor JustinianI. Actually he was scared to death and was about to leave the city but his wife Theodora made a speech and changed the destiny. She convinced Justinian to stay and fight instead of leaving like a coward. And Justinian sent his famous and glorious general Belisarius to handle the rioters. And he did it very well, killed them all in Hippodrome in 532. But it was too late for second Hagia Sophia.
10 days after the riots Justinian started to build a new church, a much bigger one and brought the best architects and workers of the country. They completed the work in five years and ten months and the third Hagia Sophia was opened for services in 537.It was the greatest church of the Eastern Roman Empire at that time and used as a church up until 1453.
When the Ottoman conquered the city, as a tradition, it was converted into a mosque and was a mosque till 1935.
It was then converted into a museum by the order of Ataturk, the founder of the Turkish Republic, and is a museum now.
It is open every day except Monday, from 9 AM to 4 PM and the entrance fee is 40 Turkish Lira. They do not accept any other currency but the credit card is okay. The present building is mostly original and in extremely good condition. At the inside of the building it is possible to see some Christian icons, Islamic additions made by the Ottomans.