During the seven years of his 19,000-kilometre journey (1046–1052), Nasir visited Mecca four times, and performed all the rites and observances of a zealous pilgrim; but he was far more attracted by Cairo, the capital of Egypt, and the residence of the Fatimid caliph-imam Ma'ad al-Mustansir Billah, the Imam of the Ismaili Shi'a Muslims, which was just then waging a deadly war against the Abbasid caliph of Baghdad, and Toghrul Beg the Seljuk, the great defender of the Sunni creed. At the very time of Nasir's visit to Cairo, the power of the Egyptian Fatimids was in its zenith; Syria, the Hejaz, Africa, and Sicily obeyed al-Mustansir's sway, and the utmost order, security and prosperity reigned in Egypt.