In many parts of the Muslim world, caravanserais also provided revenues that were used to fund charitable or religious functions or buildings. These revenues and functions were managed through a "waqf", a protected agreement which gave certain buildings and revenues the status of mortmain endowments guaranteed under Islamic law. Many major religious complexes in the Ottoman and Mamluk empires, for example, either included a caravanserai building (like in the "külliye" of the Süleymaniye Mosque in Istanbul) or drew revenues from one in the area (such as the Wikala al-Ghuri in Cairo, which was built to contribute revenues for the nearby complex of Sultan al-Ghuri).