كتاب الزهد والرقائق
55  
The Book of Zuhd and Softening of Hearts
(1)
Chapter: The Prohibition Of Entering Upon The People Of Al-Hijr (The Rocky Tract) Unless One Enters Weeping
(1)
باب لاَ تَدْخُلُوا مَسَاكِنَ الَّذِينَ ظَلَمُوا أَنْفُسَهُمْ إِلاَّ أَنْ تَكُونُوا بَاكِينَ ‏.‏
Sahih Muslim 2980 b

Ibn Shihab reported, and he had been talking about the stony abodes of Thamud, and he said:

Salim b. 'Abdullah reported that 'Abdullah b. Umar said: We were passing along with Allah's Messenger (ﷺ) through the habitations of Hijr, and Allah's Messenger (ﷺ) said: Do not enter but weepingly the habitations of these persons who committed tyranny among themselves, lest the same calamity should fall upon you as it fell upon them. He then urged his mount to proceed quickly and pass through that valley hurriedly.
حَدَّثَنِي حَرْمَلَةُ بْنُ يَحْيَى، أَخْبَرَنَا ابْنُ وَهْبٍ، أَخْبَرَنِي يُونُسُ، عَنِ ابْنِ شِهَابٍ، - وَهُوَ يَذْكُرُ الْحِجْرَ مَسَاكِنَ ثَمُودَ - قَالَ سَالِمُ بْنُ عَبْدِ اللَّهِ إِنَّ عَبْدَ اللَّهِ بْنَ عُمَرَ قَالَ مَرَرْنَا مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم عَلَى الْحِجْرِ فَقَالَ لَنَا رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ لاَ تَدْخُلُوا مَسَاكِنَ الَّذِينَ ظَلَمُوا أَنْفُسَهُمْ إِلاَّ أَنْ تَكُونُوا بَاكِينَ حَذَرًا أَنْ يُصِيبَكُمْ مِثْلُ مَا أَصَابَهُمْ ‏"‏ ‏.‏ ثُمَّ زَجَرَ فَأَسْرَعَ حَتَّى خَلَّفَهَا ‏.‏
Reference : Sahih Muslim 2980b
In-book reference : Book 55, Hadith 48
USC-MSA web (English) reference : Book 42, Hadith 7104
  (deprecated numbering scheme)