Throughout Byzantine and Ottoman history, the Hagia Sophia has been the Imperial Church or Mosque.