كتاب الجنائز
11  
The Book of Prayer - Funerals
(34)
Chapter: Offering the funeral prayer in the masjid
(34)
باب الصَّلاَةِ عَلَى الْجَنَازَةِ فِي الْمَسْجِدِ ‏‏
Sahih Muslim 973 b

'Abbad b. 'Abdullah b. Zubair reported on the authority of 'A'isha that when Sa'd b. Abu Waqqas died, the wives of the Messenger of Allah (ﷺ) sent message to bring his bier into the mosque so that they should offer prayer for him. They (the participants of the funeral) did accordingly, and it was placed in front of their apartments and they offered prayer for him. It was brought out of the door (known as) Bab al-Jana'iz which was towards the side of Maqa'id, and the news reached them (the wives of the Holy Prophet) that the people bad criticised this (i. e. offering of funeral prayer in the mosque) saying that it was not desirable to take the bier inside the mosque. This was conveyed to 'A'isha. She said:

How hastily the people criticise that about which they know little. They criticise us for carrying the bier in the mosque. The Messenger of Allah (ﷺ) offered not the funeral prayer of Suhail b. Baida' but in the innermost part of the mosque.
وَحَدَّثَنِي مُحَمَّدُ بْنُ حَاتِمٍ، حَدَّثَنَا بَهْزٌ، حَدَّثَنَا وُهَيْبٌ، حَدَّثَنَا مُوسَى بْنُ عُقْبَةَ، عَنْ عَبْدِ الْوَاحِدِ، عَنْ عَبَّادِ بْنِ عَبْدِ اللَّهِ بْنِ الزُّبَيْرِ، يُحَدِّثُ عَنْ عَائِشَةَ، أَنَّهَا لَمَّا تُوُفِّيَ سَعْدُ بْنُ أَبِي وَقَّاصٍ أَرْسَلَ أَزْوَاجُ النَّبِيِّ صلى الله عليه وسلم أَنْ يَمُرُّوا بِجَنَازَتِهِ فِي الْمَسْجِدِ فَيُصَلِّينَ عَلَيْهِ فَفَعَلُوا فَوُقِفَ بِهِ عَلَى حُجَرِهِنَّ يُصَلِّينَ عَلَيْهِ أُخْرِجَ بِهِ مِنْ بَابِ الْجَنَائِزِ الَّذِي كَانَ إِلَى الْمَقَاعِدِ فَبَلَغَهُنَّ أَنَّ النَّاسَ عَابُوا ذَلِكَ وَقَالُوا مَا كَانَتِ الْجَنَائِزُ يُدْخَلُ بِهَا الْمَسْجِدَ ‏.‏ فَبَلَغَ ذَلِكَ عَائِشَةَ فَقَالَتْ مَا أَسْرَعَ النَّاسَ إِلَى أَنْ يَعِيبُوا مَا لاَ عِلْمَ لَهُمْ بِهِ ‏.‏ عَابُوا عَلَيْنَا أَنْ يُمَرَّ بِجَنَازَةٍ فِي الْمَسْجِدِ وَمَا صَلَّى رَسُولُ اللَّهِ صلى الله عليه وسلم عَلَى سُهَيْلِ ابْنِ بَيْضَاءَ إِلاَّ فِي جَوْفِ الْمَسْجِدِ ‏.‏
Reference : Sahih Muslim 973b
In-book reference : Book 11, Hadith 129
USC-MSA web (English) reference : Book 4, Hadith 2124
  (deprecated numbering scheme)