Commercial insurance is haraam, because it is a kind of gambling which Allaah has forbidden in His Book. This has been explained in the answer to question no. 8889.
Based on this, it is not permissible to enter into commercial insurance transactions, whether the insurance is against fire or anything else, and whether it is for the mosque or anything else. If a person is compelled to take out insurance, then he may do that, but he does not have the right to make use of the money paid by the insurance, except that which is commensurate with what he paid. Anything more than that should be spent on the public interests of the Muslims, which includes building mosques. The scholars have stated that this is one of the things on which haraam wealth which does not have a specific owner or whose owner is not known may be spent.
Al-Nawawi said in al-Majmoo’ (9/330), quoting from al-Ghazali about the disposal of haraam wealth:
If it belongs to someone who is unknown and there is no hope of finding the owner, then it should be spent in the public interests of the Muslims, such as bridges, mosques and so on which are shared by the Muslims; otherwise it may be given in charity to one or more poor persons. End quote.
Thus it is known that there is nothing wrong with spending the money acquired via haraam transactions on building mosques. That includes insurance money, whether it is in a Muslim country or elsewhere. For more information please see question no. 75410.
And Allaah knows best.