Answer
Wa `alaykum as-salamu wa rahmatullahi wa barakatuh.
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:
No one has the right to extort a span of the hand of land unlawfully, especially a public land like a street, etc. This is completely forbidden in Islam even if this land belongs to non-Muslims. If you are sure that the mosque was built on a fraudulently appropriated land, then you should not pray in it.
In his response to your question, Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states:
If you have reasonable grounds to believe that the land the person donated for the mosque was fraudulently appropriated, then it is haram to pray in it, according to the vast majority of scholars and jurists belonging to various schools. For, by praying in such a mosque, we are condoning acts of robbery and injustice.
A mosque is a place to disseminate Allah’s word. The Prophet (peace and blessings of Allah be upon him) was told not to pray in masjid ad-dirar (the Mosque of Harm) built by hypocrites and the fifth column in Madinah, who had built it in order to turn people against Islam and foment dissension and division in the Muslim community.
If, on the other hand, the mosque is built on the land that rightfully belongs to him, then there is nothing wrong in praying there even though he may have other unlawful earnings or possessions in his hands.
For, in this case, it is the case of a man who has both lawful and unlawful incomes, and as long as the donation comes from his lawful earnings, we are allowed to accept it, although we must reject that which he gives from his unlawful earnings.
Abu Bakr, the first caliph, (may Allah be pleased with him) accepted the gift of food from his client, who had both lawful and unlawful earnings. However, when he discovered that it was purchased by money earned through soothsaying he induced vomiting!
For more see these fatwas:
Is Auctioning Off Items Donated to the Mosque Allowed?
Using External Mosque Premises for Business Purposes
Allah Almighty knows best.