Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.053.

Section : Offering Funeral Prayer in a Mosque.

There is no harm in offering funeral prayer in a mosque, if there is no danger of it becoming unclean. This is based on a narration of Muslim from ‘Aishah who said: “The Prophet, peace be upon him, offered a funeral prayer for Suhail ibn Baida in the mosque, and the Companions likewise offered funeral prayer for Abu Bakr and ‘Umar in the mosque, and no one objected to it, because the funeral prayer is similar to other (formal) prayer. ‘

Abu Hanifah and Malik do not approve of it, citing a hadith of the Prophet, peace be upon him, to the effect that whoever offers a funeral prayer in the mosque would have nothing (i.e. no reward). This statement not only contradicts the practice of the Prophet, peace be upon him, and his Companions, but is also a weak hadith due to other reasons. Ahmad ibn Hanbal said: “This is a weak hadith, and is reported through a single transmitter, Salih, the freed slave of Al-Tawamah, and he is an unreliable narrator. Some scholars, however, hold that this hadith of the Prophet, peace be upon him, is sound, and the words, reported by Abu Daw’ud, “Whoever offers a funeral prayer in a mosque would have nothing,” mean such a person would not incur any burden (of sin). Ibn AlQayyim said: ‘It was not the usual practice of the Prophet, peace be upon him, to offer a funeral prayer in the mosque. Rather he would usually offer funeral prayers outside the mosque except when for some reason he had to offer it in the mosque. In certain cases he did offer funeral prayer in the mosque, as in the case of Ibn Baida, which shows that funeral prayer may be offered either inside or outside the mosque, but to do so outside the mosque is preferable.”