Hagia Sophia which is in Sultanahmet district of Fatih municipality ,is opposite to the Sultanahmet (Camii) Mosque.
You can go Sultanahmet using various types of transportatians like metro, metrobuses and reach to Beyazit, Sirkeci, Cankurtaran or Catladi Kapi districts after that you can use tramlines or even walk down the rest of the way.
Sultanahmet is partially closed to the car traffic. If you prefer coming from Aksaray district (Avcılar-Beylikduzu), you can easily hop on one of the buses which are cheaper than taxis and arrive at Beyazıt. Then, within 10 mins walk you pass Cemberlitas and there you find yourself in the magical atmosphere of Sultanahmet. For ones who do not want to walk, trams are the best choice because it’s only two stations ahead.
On Sundays, the streets between Aksaray and Beyazit are closed to the car traffic. Because of this regulation which is valid only for Sundays, if you are concerning to visit Sultanahmet , you better keep in mind that buses doesnt stop at Beyazıt so you should get off the bus at Aksaray. Then you can use tramline to reach Sultanahmet less then 10 mins.
The tram line route goes from the district of Bağcılar via Zeytinburnu on the shore of the Sea of Marmara , Beşiktaş/ Kabataş through Sultanahmet and passes by Ayasofya.
If you are coming from Beşiktaş , again, you can use the trams.
For reaching Ayasofya from Ataturk Airport, you need to use metro line and get off at the Aksaray station. Then you use metro on the street (Millet Caddesi) to arrive easily at Sultanahmet.
If you want to drive to Beyazit instead, you can easily find a parking spot and park your own car there.
Using the coastal road while driving is a good option because of the nice scenery. After you arrive at Sirkeci there you can leave your car at the nearest parking garage and get on the tram or by walking approximately half an hour, from the Gulhane Park direction, you can reach to Hagia Sophia.
Those who want to come from the Asian side of Istanbul need to cross the sea first by ferries or use Marmaray metro line, then they use the same route we mentioned before.
While coming with your car, you should use the coastal road and pass under the Catladi Kapi bridge then reach to the Sultanahmet Mosque by using the straight road and park at the Istanbul Trafik Vakfi garage. That would be my best suggestion for you.
From there, you can walk couple of minutes and there you are , at Sultanahmet square and in front of Hagia Sophia. There are so many available parking spaces , so this way is a better choice for the car owners. They turned Sultanahmet Camii’s once closed yard into a parking garage which is now a legal garage and it belongs to Istanbul Traffic Foundation.That’s why it’s a quite safe place to leave your cars.