What is the ruling making a construction over a Mosque?
All perfect praise be to Allah, The Lord of The Worlds and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
The Mosque has a noble and eminent rank in Islam whereas it has its own rulings according to jurists; expressly, if a building was established for a purpose of allocating it as a mosque then constructing an additional building above it is impermissible, because according to the majority of Muslim jurists what lies above a mosque takes its ruling. In this regard, the author of [Al-Durr Al-Mukhtar], one of Hanafiee's scholars, stated:" Making ablution, urinating and defecating above a mosque is an abominable matter that is almost unlawful, since the extent of the mosque from above is to the heaven/firmament."
Besides, it is stated: "Constructing an additional building above a mosque for the Imam is impermissible." [Rd Al-Mukhtar vol.3 pp.371].
Moreover, the Jordanian Board of Iftaa', Research and Islamic Studies stated:" Building rooms meant for teaching the recitation of Quran above a mosque is impermissible, due to the fact that a mosque is built in the first place for the performance of prayers only and what lies above and beneath it takes the same ruling; in addition, adding additional floors or apartments in the same building of a Mosque will render the latter to a normal building and opens the door for adding more and more buildings above mosques in general in which the main purpose for which they were built will be a secondary one."
As for choosing a floor or part of a building that already existed for the purpose of establishing a mosque in that building is permissible, because the entire building is already owned and not endowed or set to be a mosque in the first place. And Allah knows best.