Toilets below or above the masjid
A Masjid is a sancitified area. A place which has been permanently dedicated to Allah for the sake of prayer, recitation of the Holy Quran and his remembrance. Once a Masjid is erected, it will always be a masjid. It cannot return to the property of the community. (Raddul Muhtar p.371 v.3 & Tahtawi p.172 v.4)
The areas above and below the masjid are considered to be part of the masjid (Fatawa Mahmoodiyah p.162 v.18), therefore it is not permissible to build a shop, or rooms or toilets above or below the masjid.
It should be borne in mind that this ruling only applies after the area has become a masjid. Before a masjid is made, it will be permissible to exclude areas above or below if it is for the benefit of the masjid, for example designating an ablution area for the musalles and building a library. (Fatawa Mahmoodiyah p.229 v.17)
However, with regards to making toilets and rooms for the Imam and his family to reside either above or below the masjid will not be allowed, even during the masjids initial design since it is impermissible to have sexual relations, relieve oneself etc above or below the masjid. (Hidayah p.144 v.1 & Fatawa Mahmoodiyah p.218 v.18)
The conclusion we can come to is that it is permissible to build toilets and rooms for the Imam next to or in an area adjacient to the masjid. However, it will not be permissible above or below the masjid, even during the masjids initial design.
Only Allah Knows Best
Mohammed Tosir Miah
Darul Ifta Birmingham