Question: What is the ruling on prayer in a masjid built from impermissible wealth?
Answer: “Prayer in it is permissible and there is no harm in it because the one who built it upon impermissible wealth sometimes intends in its building to dispose of impermissible wealth which he earned. In that case, his building of the masjid would be permissible if he intended to dispose of impermissible wealth. If he is disposing of impermissible wealth he does not specify [his action or intention ] with building the Masaajid. Rather if a person gives it in a legislated good deed, then he has freed himself from it.
As for if the land of the masjid is seized land, then this is an issue of debate between the scholars. From the scholars are those that say prayer on seized land is invalid, nullified and from them is the scholar that says it is valid and the sin is upon the one who seized it”.
[Taken from: https://goo.gl/PtxFA8 ]
Faisal Ibn Abdul Qaadir Ibn Hassan