Language:
كتاب الصلاة
8  
Prayers (Salat)
(84)
Chapter: The religious gathering in circles and sitting in the mosque
(84)
باب الْحِلَقِ وَالْجُلُوسِ فِي الْمَسْجِدِ
Sahih al-Bukhari 474

Narrated Abu Waqid al-Laithi:

While Allah's Messenger (ﷺ) was sitting in the mosque (with some people) three men came, two of them came in front of Allah's Messenger (ﷺ) and the third one went away, and then one of them found a place in the circle and sat there while the second man sat behind the gathering, and the third one went away. When Allah's Messenger (ﷺ) finished his preaching, he said, "Shall I tell you about these three persons? One of them betook himself to Allah and so Allah accepted him and accommodated him; the second felt shy before Allah so Allah did the same for him and sheltered him in His Mercy (and did not punish him), while the third turned his face from Allah, and went away, so Allah turned His face from him likewise.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ يُوسُفَ، قَالَ أَخْبَرَنَا مَالِكٌ، عَنْ إِسْحَاقَ بْنِ عَبْدِ اللَّهِ بْنِ أَبِي طَلْحَةَ، أَنَّ أَبَا مُرَّةَ، مَوْلَى عَقِيلِ بْنِ أَبِي طَالِبٍ أَخْبَرَهُ عَنْ أَبِي وَاقِدٍ اللَّيْثِيِّ، قَالَ بَيْنَمَا رَسُولُ اللَّهِ صلى الله عليه وسلم فِي الْمَسْجِدِ فَأَقْبَلَ ثَلاَثَةُ نَفَرٍ، فَأَقْبَلَ اثْنَانِ إِلَى رَسُولِ اللَّهِ صلى الله عليه وسلم وَذَهَبَ وَاحِدٌ، فَأَمَّا أَحَدُهُمَا فَرَأَى فُرْجَةً فَجَلَسَ، وَأَمَّا الآخَرُ فَجَلَسَ خَلْفَهُمْ، فَلَمَّا فَرَغَ رَسُولُ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ أَلاَ أُخْبِرُكُمْ عَنِ الثَّلاَثَةِ أَمَّا أَحَدُهُمْ فَأَوَى إِلَى اللَّهِ، فَآوَاهُ اللَّهُ، وَأَمَّا الآخَرُ فَاسْتَحْيَا، فَاسْتَحْيَا اللَّهُ مِنْهُ، وَأَمَّا الآخَرُ فَأَعْرَضَ، فَأَعْرَضَ اللَّهُ عَنْهُ ‏"‏‏.‏
Reference : Sahih al-Bukhari 474
In-book reference : Book 8, Hadith 122
USC-MSA web (English) reference : Vol. 1, Book 8, Hadith 463
  (deprecated numbering scheme)