Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
It is lawful to use government lottery money in building this mosque, although it is more appropriate to use only money from halal means.
Answering your question, The Fatwa Center at Islamweb, states:
It is lawful to use government lottery money in building this mosque, although it is more appropriate to use only money from halal means.
We remind you that the reason for lawfulness is limited to the fact that the money is actually in your hand.
Now, if you have to look for it for the purpose of building the mosque, then that is unlawful as the aim does not justify the means.
Using the government lottery money is lawful only if the money is already in your hand because one of the ways of getting rid of haram money is to spend it in good things that have a general interest for Muslims like building mosques.
Almighty Allah knows best.
Source: www.islamweb.net