When there is a need, the funeral prayer may also be performed in the mosque.
➊ It is narrated from Aisha (may Allah be pleased with her) that:
والله لقد صلى رسول الله على ابنى بيضاء فى المسجد
“By Allah, the Messenger of Allah ﷺ prayed the funeral prayer for the two sons of Bayda’ in the mosque.”
➋ It is narrated from Ibn Umar (may Allah be pleased with them both) that:
صلى على عمر فى المسجد
“The funeral prayer for Umar (may Allah be pleased with him) was prayed in the mosque.”
➌ Umar (may Allah be pleased with him) prayed the funeral prayer for Abu Bakr (may Allah be pleased with him) in the mosque.
(The majority, Ahmad (may Allah have mercy on him), Shafi’i (may Allah have mercy on him)) hold this view.
(Abu Hanifa (may Allah have mercy on him), Malik (may Allah have mercy on him)) hold that praying the funeral prayer in the mosque is disliked.
Remember that there is no evidence for it being disliked.
(Albani (may Allah have mercy on him)) The funeral prayer in the mosque is permissible, but it is better to pray the funeral prayer outside the mosque in the funeral prayer ground, as (for the most part) this is how it was done in the time of the Prophet ﷺ.
(Bukhari (may Allah have mercy on him)) He has established a chapter in Sahih al-Bukhari as follows:
الصلاة على الجنائز بالمصلى والمسجد
“Praying the funeral prayer in both the funeral prayer ground and the mosque (is correct).”