Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:4272Abū al-Ḥasan Muḥammad b. al-Ḥusayn b. Dāwud al-ʿAlawī Imlāʾ > Abū Ḥāmid b. Muḥammad b. al-Ḥasan al-Ḥāfiẓ > Muḥammad b. Yaḥyá al-Dhuhlī > Yazīd b. Hārūn > Sufyān al-Thawrī > ʿAmr b. Yaḥyá > Abīh And Ḥammād b. Salamah > ʿAmr b. Yaḥyá from his father > Abū Saʿīd

[Machine] The Messenger of Allah ﷺ said, "The whole earth is a mosque except for the graveyard and the bathroom." This hadith of Al-Thawri is marfu' (attributed directly to the Prophet) and has been reported continuously. Additionally, the hadith of Hammad ibn Salamah is also marfu', and it has been followed in its chain by Abd al-Wahid ibn Ziyad and Al-Daraqutni.  

البيهقي:٤٢٧٢حَدَّثَنَا أَبُو الْحَسَنِ مُحَمَّدُ بْنُ الْحُسَيْنِ بْنِ دَاوُدَ الْعَلَوِيُّ إِمْلَاءً أنبأ أَبُو حَامِدِ بْنُ مُحَمَّدِ بْنِ الْحَسَنِ الْحَافِظُ ثنا مُحَمَّدُ بْنُ يَحْيَى الذُّهْلِيُّ ثنا يَزِيدُ بْنُ هَارُونَ أنبأ سُفْيَانُ الثَّوْرِيُّ عَنْ عَمْرِو بْنِ يَحْيَى عَنْ أَبِيهِ وَحَمَّادِ بْنِ سَلَمَةَ عَنْ عَمْرِو بْنِ يَحْيَى عَنْ أَبِيهِ عَنْ أَبِي سَعِيدٍ قَالَ

قَالَ رَسُولُ اللهِ ﷺ الْأَرْضُ كُلُّهَا مَسْجِدٌ إِلَّا الْمَقْبَرَةَ وَالْحَمَّامَ حَدِيثُ الثَّوْرِيِّ مُرْسَلٌ وَقَدْ رُوِيَ مَوْصُولًا وَلَيْسَ بِشَيْءٍ وَحَدِيثُ حَمَّادِ بْنِ سَلَمَةَ مَوْصُولٌ وَقَدْ تَابَعَهُ عَلَى وَصْلِهِ عَبْدُ الْوَاحِدِ بْنُ زِيَادٍ وَالدَّرَاوَرْدِيُّ