Successive Muslim caliphs, and later the Mamluk sultans, were the prime protectors of the Holy cities of the Hijaz. As a result, they were responsible for all refurbishments and maintenance of the
Haram in Mecca as well as the
mosque and tomb of the Prophet in
Medina. In order to finance these ongoing commitments, the Mamluk
Sultan Qaytbay (r. 872–901 / 1468–96) established a
wikala in Cairo, the income from which was dedicated to the provision of grain and other charitable donations to the needy living in the vicinity of the Holy Sites of Mecca and
Medina.