Question
Is it permissible to pray the funeral prayer in the courtyard of the mosque or not?
Answer
The funeral prayer is permissible in the mosque. The Prophet ﷺ himself prayed it there. The funeral prayers of Abu Bakr (may Allah be pleased with him) and Umar (may Allah be pleased with him) were prayed in the mosque. واللہ اعلم
Explanation
According to the authentic (sahih) hadith, praying the funeral prayer in the mosque is permissible and correct. It is stated in Muntaqa al-Akhbar:
عن عائشة انها قالت لما توفي سعد بن أبى وقاص قالت ادخلوا به المسجد حتٰي اصلي عليه فانكروا ذلك عليها فقالت لقد صلى الله عليه وسلم على ابني بيضاء فى المسجد سهيل واخيه رواه مسلم
وفي روايت ما صلى رسول الله صلى الله عليه وسلم على سهيل بن البضاء إلا فى جوف المسجد رواه الجماعة البخاري
This hadith establishes that the Messenger of Allah ﷺ prayed the funeral prayer in the mosque. And the funeral prayers of Abu Bakr (may Allah be pleased with him) and Umar (may Allah be pleased with him) were also prayed in the mosque, which proves that the Companions (may Allah be pleased with them) were in consensus and agreement that the funeral prayer in the mosque is correct and permissible. It is stated in Fath al-Bari:
وقد روي ابن ابي شيبة وغيره أن عمر صلّى عل أبى بكر فى المسجد وان مهيبا صلّٰي على عمر فى المسجد وفي رواية ووضعت الجنازة فى المسجد تجاه المنبرو هذا يقتضي الاجماع على جواز ذلك الخ