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:4327Abū Aḥmad al-Ḥāfiẓ

[Machine] And Abu Hazim reported that Abu Ahmad Al-Hafiz reported that Abu Al-Abbas Al-Thaqafi narrated that Muhammad ibn Raffi narrated from Abdul Razzaq that Mammar reported from Abdul Karim from Abu Ubaydah ibn Abdullah from Ibn Mas'ud that he used to permit the one in a state of major ritual impurity (junub) to pass through the mosque as long as he was just passing by. He said, "And I only know this from the statement, 'And not in a state of junub, except those passing through [a place of prayer]'." (Quran 4:43)  

البيهقي:٤٣٢٧

وَأنبأ أَبُو حَازِمٍ أنبأ أَبُو أَحْمَدَ الْحَافِظُ أنبأ أَبُو الْعَبَّاسِ الثَّقَفِيُّ ثنا مُحَمَّدُ بْنُ رَافِعٍ ثنا عَبْدُ الرَّزَّاقِ أنبأ مَعْمَرٌ عَنْ عَبْدِ الْكَرِيمِ عَنْ أَبِي عُبَيْدَةَ بْنِ عَبْدِ اللهِ عَنِ ابْنِ مَسْعُودٍ أَنَّهُ كَانَ يُرَخِّصُ لِلْجُنُبِ أَنْ يَمُرَّ فِي الْمَسْجِدِ مُجْتَازًا قَالَ وَلَا أَعْلَمُهُ إِلَّا قَالَ {وَلَا جُنُبًا} [النساء 43] إِلَّا عَابِرِي سَبِيلٍ