Praise be to Allah.
The wealth that has been allocated for a public interest, such as mosques or to be given to the poor, is not subject to zakaah, because it is not owned by a particular individual.
An-Nawawi (may Allah have mercy on him) said in al-Majmoo‘ (5/311): If the livestock has been allocated for a public interest, such as the poor, mosques, fighters in Allah’s cause, orphans and the like, then no zakaah is due on it, because it does not belong to a particular individual. End quote.
He also said: If the fruits of a garden or the harvest of the land is a waqf, meaning that it is allocated for a public interest, such as mosques, bridges, schools, the poor, fighters in Allah’s cause, wayfarers, orphans, widows, and the like, then no zakaah is due on it.… If it has been allocated to a specific individual, or a specific group of people, or for the children of Zayd, for example, then ten percent is due on it [as zakaah], and there is no difference of scholarly opinion concerning that, because they own the fruits and the harvest in a complete sense, and they can dispose of it in all ways. End quote from al-Majmoo‘ (5/483).
In al-Furoo‘ (2/336), it says: There is no zakaah on a waqf that is not allocated to a specific individual, or a waqf that is allocated for mosques, schools, border posts, and the like. End quote.
Shaykh Ibn Baaz (may Allah have mercy on him) was asked:
I have a sum of money that was donated by some good people for building a mosque, and it has been with me for more than a year. Is zakaah due on it or not?
He replied: No zakaah is due on it at all, because those people gave it in Allah’s cause. But you should hasten to carry out their wishes concerning it.
End quote from Majmoo‘ al-Fataawa (14/37).
So there is no zakaah due on money that has been collected to build a mosque.
And Allah knows best.