Praise be to Allah.
The fact that the Shi‘ah participated in the building of this mosque does not mean that one cannot pray in it.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
As for simply building mosques, it is permissible for them to be built by righteous and evildoers, Muslims and non-Muslims.
End quote from Majmoo‘ al-Fataawa (17/499)
Shaykh Saalih al-Fawzaan (may Allah preserve him) was asked:
Is it permissible to pray in a mosque that was built by a non-Muslim at his own expense?
There is nothing wrong with that, so long as it was not done for an ulterior motive such as calling people to disbelief and so on. If it was built without any ulterior motive, then there is nothing wrong with praying in it.
If prayer offered in a mosque that was built by a disbeliever is valid, then it is more appropriate that prayers offered in a mosque in which some followers of innovation participated in the construction thereof should also be valid.
The view of those who say that it is not permissible to pray in this mosque because the Shi‘ah are the ones who built it is a view that is not correct.
Allah, may He be exalted, says (interpretation of the meaning):
“And the mosques are for Allah (Alone), so invoke not anyone along with Allah” [al-Jinn 72:18].
So the Muslims must defend the houses of Allah which He has caused to be built and His name to be mentioned therein, and which He has described as His by way of honour, and not give them up to disbelievers or followers of innovation.
Because the dispute concerning this mosque is between two groups, one of which follows correct Salafi ‘aqeedah and the other follows a deviant ‘aqeedah, it is essential for the followers of the sound ‘aqeedah to hold on to it and not leave it for the followers of innovation and deviance, especially as there is no other mosque in the city apart from this one, and it is not possible to build another, for if the followers of true faith leave it for the followers of innovation, they will end up without a mosque, and they will be leaving the house of Allah to these deviants to establish their innovation in it, and they may ascribe partners to Allah in it.
If it so happens that the Sunnis are only able to have control of the upper floor of this building, undoubtedly this is better for them than not having any place at all, and it is better for them than being deprived of a place in which they can hold their Jumu‘ah prayers and daily prayers in congregation, and spread their call to Allah. So they have to hold onto it and not give it up or hand it over to this deviant group. Their prayers in that place are valid and their worship therein is acceptable, in sha Allah. It is clear from the question how important it is that there be a Sunni presence in that place, because they had a good influenced on others and some people embraced the way of the salaf and have given up their innovation. Allah, may He be exalted, says (interpretation of the meaning): “So keep your duty to Allah and fear Him as much as you can” [at-Taghaabun 64:16].
Shaykh as-Sa‘di (may Allah have mercy on him) said:
This verse indicates that if an individual is unable to do an obligatory duty, it is waived in his case, but if he is able to do part of what is enjoined and unable to do part, then he must do whatever he is able to do, and what he is not able to do is waived in his case, as the Prophet (blessings and peace of Allah be upon him) said: “If I instruct you to do something, then do as much of it as you can.” Agreed upon.
This shar‘i principle is applicable to innumerable minor issues.
End quote from Tafseer as-Sa‘di (p. 86 8)
Undoubtedly leaving this place completely in the hands of the Raafidis would constitute barring the path of Allah, as is quite obvious to any wise person, and would be a cause of many Sunnis giving up Jumu‘ah prayer and prayers in congregation altogether, so that they would not offer these prayers with the Raafidis.
It would also be a cause of enabling the followers of innovation to establish their call without any of the Sunnis standing up to them.
Masjid ad-diraar is the mosque that was built on a basis of disbelief and hypocrisy, and to cause division among the believers and help the hypocrites and disbelievers. What does this have to do with crowding out the followers of falsehood and saving part of the mosque so that the name of Allah may be mentioned therein and His symbols may be venerated?
All of this is based on the assumption that the two floors are connected, with no division between them. But if the upper floor is completely separate from the lower floor, such as if the space is above the mosque and is separate from it, then that is less likely to cause confusion. In that case these are two completely separate mosques, each of which comes under its own ruling, according to the purpose for which it was built and the rituals that are conducted in it.
And Allah knows best.