The prophet of Allah, may Allah’s peace and blessings be upon him said: Verily, Allah is pure and He accepts nothing but pure’. Whoever wants to participate or contribute in the building of a mosque or any charitable act must present clean money. It is far better than usury, even if it ( the clean money) is small.
However, in a situation whereby a person is having money that comes from a suspicious means, and he intends to get rid of it by depositing it in the building of a mosque, there is no objection to this if it will be used for mosque’s utilities. On condition that he will not return to using usury again, neither should he use the contribution/donation a means for dealing with usury, because usury is forbidden.