Wa alaikum assalam wa rahmatullahi wa barakatuh.
If a mosque is no longer in use due to demolition, people leaving it or any other reasons such that prayer is no longer performed inside it then it is permissible to sell it and convert it to another use according to the correct of the two scholarly views on the issue. This is because leaving the old mosque inactive after its demolition or people leaving it defeats the objective of endowment and is contrary to the interest of the creator of an endowment. This is based on the act of ‘Umar (may Allah be pleased with him) when the building that housed the Muslim public treasury was perforated he instructed Ibn Mas’ud to move the Kufah Mosque from its place. ‘Umar moved the mosque when it was not inactive but he did this in the interest of securing and protecting the Muslim public treasury. It is permissible to move or dispose and endowment if that serves a purpose. Based on this, what is best and more appropriate would be selling the old mosque and using the money to build a new mosque if it is possible. If you find someone who can buy the old mosque then sell it and use that money to build another mosque in place of the old one. The buyer can do whatever he likes with the old mosque due to absence of mosque rulings on the building. When ‘Umar instructed that Kufah Mosque be moved, he made it a market for dates and it was known as the dates merchants' market. Therefore the buyers of the old mosque can use it as an office, shops or anything he wishes. If he endows it as a utility to the new mosque such as house for the Imam and muezzin, then that would be good.
If there is no one available to buy the old mosque or there is an impediment to that, then I do not think that there is any objection on converting the old mosque into houses for the Imam and muezzin. This is because leaving an endowment inactive leads to losing its benefits altogether whereas using it to house the Imam and muezzin protects it from being inactive although converting it into houses of Imam and muezzin is in reality changing the type of endowment. However this is permissible according to a correct of the two scholarly opinions because it is part of perfecting the utilities of the mosque. In al-Ikhtiyaraat, Shaykh al-Islam said: " The majority of scholars are of the opinion that it is permissible to change an endowment for a beneficial reason, like converting houses into shops.” All this should be done after getting consent from the endower or its administrator, whether it is a person or an organization. And Allah knows best and may Allah’s peace and blessings be upon the Messenger of Allah Muhammad, his family and all his companions.
Dr. Khalid al-Mosleh,
Member of Iftaa Department
Lecturer of Islamic Jurisprudence, Qaseem University.