Under the direction of Khoshiar Hanem, Khedive Ismail's mother, work on the Al Rifai Mosque started in 1869 with the intention of constructing a stately religious institution that would act as a mausoleum for the Muhammad Ali Dynasty. The mosque was built as a compliment to the 14th-century Sultan Hassan Mosque, which is located nearby. But under Khedive Abbas Helmy II's rule, building was put on hold for a number of years due to political unrest and financial issues, and it wasn't finished until 1912.
The mosque bears the name of Ahmad Al Rifai, the founder of the Rifai Sufi order and a renowned Islamic philosopher from the 12th century. The mosque's commitment to Sufi teachings was motivated by his spiritual legacy, even though he was never laid to rest here. Al Rifai Mosque has served as the final resting place for a number of Egyptian monarchs over the years, including Shah Mohammad Reza Pahlavi, the exiled Shah of Iran, and King Farouk, the last king of Egypt.