In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
Answering your question, the General Iftaa’ Department in Jordan, states the following:
It isn’t permissible to use the land which is endowed for the benefit of the mosque against the purpose for which it was endowed since the condition of the person who endowed it equals the evidence established in the Shari`ah texts.
In principle, an endowment shouldn’t be sold, gifted, or inherited; rather, it should observe the purpose for which it was endowed. Ibn `Umar reported: “`Umar acquired a land at Khaibar. He came to Allah’s Apostle (peace be upon him) and sought his advice in regard to it. He said: Allah’s Messenger, I have acquired land in Khaibar. I have never acquired property more valuable for me than this, so what do you command me to do with it? Thereupon he (Allah’s Messenger) said: If you like, you may keep the corpus intact and give its produce as charity. So `Umar gave it as charity declaring that property must not be sold or inherited or given away as gift. And `Umar devoted it to the poor, to the nearest kin, and to the emancipation of slaves, aired in the way of Allah and guests. ” (Al-Bukhari and Muslim)
Muslim scholars have stated that violating the endower’s conditions isn’t permissible. Al-Imam Ash-Shirbini said: “In principle, the conditions of the endower should be adhered to so long as they don’t go against the purpose for which the endowment was endowed in the first place.” (Mughni Al-Muhtaj, 3/540).
A mosque is a place of prayer and worship; therefore, the above land can be used to expand it, its parking, its lavatory and the like. In addition, the aforementioned utilities pertain to the mosque; whereas, the graves don’t, so it isn’t permissible to use that land against the purpose for which it was endowed.
Almighty Allah knows best.