All that money came from Loot of India temples. The Mughals tried to buy their legitimacy in ME royalty, but to little effect.
Before 1890s, the prosperity and upkeep of the Haramain (Mecca & Medina) and Hejaz largely depended on the Indian Muslims.
Henceforth, the Ottomans referred to the Hajj as mevsim-i Hindรฎ (โthe Indian seasonโ).
The largest & most lavish grants & endowments came from Indian Muslim monarchs and aristocrats.
For instance, the Muzaffarids sultanate (just 1 out of 8 or 9 sultanates in India) used to remit 70,000 misqals of gold annually.
This sum equalled the annual revenue of the Republic of Genoa, a third of the net annual revenue of Venice at its peak, and amounted to nearly 3.5% of the total annual revenue of the Ottoman Empire.
(scroll below for sources)