First of all, we’d like to say that the role of the mosque is not restricted to being a place for performing Islamic rituals, as it also plays an important social and political role. Praying in congregation in the mosque teaches people unity. The mosque also serves as a meeting place where people discuss their problems and try to find solutions for them. It can also serve as a hospital in case of necessity. It happened in the time of the Prophet (peace and blessings be upon him) when the Muslim army came back from the Battle of Uhud: the wounded were treated in the mosque. However, after this exceptional situation ends, the mosque should be cleaned.

The prominent Muslim scholar Sheikh Muhammad Iqbal Nadvi, director and imam of Al-Falah Islamic Center, Oakville, Ontario, Canada, states: This question has many sides:

1. If the mosque is built in a way that it can be used as a place of worship and offer other services and there are other rooms available, then it can be used as a hospital as it is used for educational purpose, but not in the Prayer hall.
2. If it is not established in that way and these facilities are not available, and on the other hand, the demand is huge, then under the law of darurah (necessity) in Islam, it can be used as an exception. This applies to cases like disasters when people have no place to go except the mosque.
In the time of the Messenger of Allah (peace and blessings be upon him) there was a lady named Umm Ash-Shifa’ who set up a tent in the courtyard of the mosque and used to treat the wounded and the sick people. It was also reported that Sa`d ibn Mu`adh was among the people that benefited from this service.
As for the najasa (impurity), it can be cleaned and removed so that it does not turn the mosque, which is supposed to be used for Prayer, dirty.
As for the case of non-Muslims, there is no wrong in providing this service for them, because to save a life is an obligation in Islam, whether the person is a Muslim or not.