أَخْبَرَنَا الشَّافِعِيُّ رَضِيَ اللَّهُ عَنْهُ، قَالَ: أَخْبَرَنَا سُفْيَانُ بْنُ عُيَيْنَةَ، عَنْ عَمْرِو بْنِ يَحْيَى الْمَازِنِيِّ، عَنْ أَبِيهِ: أَنَّ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ: "الْأَرْضُ كُلُّهَا مَسْجِدٌ إِلَّا الْمَقْبَرَةَ وَالْحَمَّامَ" . قَالَ الشَّافِعِيُّ: وَجَدْتُ هَذَا الْحَدِيثَ فِي كِتَابِي فِي مَوْضِعَيْنِ أَحَدُهُمَا مُنْقَطِعٌ، وَالْآخَرُ عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ.
It is narrated from Yahya al-Mazni that the Messenger of Allah ﷺ said: "All the earth is a mosque except for bathhouses and graveyards." Imam Shafi'i, may Allah have mercy on him, says: I have found this hadith in two places in my book, in one place as mursal (disconnected) and in another place narrated from Abu Sa'id al-Khudri, may Allah be pleased with him. He reports it from the Prophet ﷺ.