Knocking the Masjid down to build a public library

Q: Regarding your answer no. 2910 to our question registered with you under no. 2550, we wish to notify you that the village is not located in the Kingdom but in Hadramawt. The matter is not referred to the court, since the villagers built the Masjid (mosque) at their own expense. We wish to know: What will happen to the old Masjid if it is abandoned after building the new one? Is it permissible to abandon the Masjid? Is it permissible to raze the Masjid that is no longer prayed in and sell the land on which it is built in order to spend the money in charity? Please enlighten us. May Allah reward you well!

A: The old Masjid is to be sold at a public auction and its price is to be spent in building the new one or any other Masjid. May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.