Question: There is a mosque in a ruined village where no one prays, and it has money. What should the guardian do with the waqf funds that have piled up?
Answer—and Allah is the One who grants success: What appears to me—Allah knows best—is that it is permissible for the waqf’s guardian to transfer those funds to another mosque.
It is stated in Sharḥ al-Azhar in a similar case: In al-Intiṣār it says: “Its doors and timbers are to be taken for another mosque; if there is no other mosque, they are sold and their price is spent on public interests; as for the courtyard (ʿarṣah), it remains, and a fence is erected around it for fear it be polluted.” He said: Because leaving the wood and doors [in place] leads to their ruin by sun and wind, and the Prophet (May Allah bless him and his family and grant them peace) forbade squandering wealth. End.
And also in the Commentary: According to al-Qāsim and al-Wāfī: “If a mosque ends up in a desolate place, it is permissible to transfer its fittings to a mosque near the inhabited quarter.” End.
Source: Min Thimār al-ʿIlm wa al-Ḥikmah vol.2