كتاب الأيمان
27  
The Book of Oaths
(8)
Chapter: Treatment of slaves, and the expiation of one who slaps his slave
(8)
باب صُحْبَةِ الْمَمَالِيكِ وَكَفَّارَةِ مَنْ لَطَمَ عَبْدَهُ ‏‏
Sahih Muslim 1659 c

Abu Mas'ud al-Ansari reported:

When I was beating my servant, I heard a voice behind me (saying): Abu Mas'ud, bear in mind Allah has more dominance over you than you have upon him. I turned and (found him) to be Allah's Messenger (ﷺ). I said: Allah's Messenger, I set him free for the sake of Allah. Thereupon he said: Had you not done that, (the gates of) Hell would have opened for you, or the fire would have burnt you.
وَحَدَّثَنَا أَبُو كُرَيْبٍ، مُحَمَّدُ بْنُ الْعَلاَءِ حَدَّثَنَا أَبُو مُعَاوِيَةَ، حَدَّثَنَا الأَعْمَشُ، عَنْ إِبْرَاهِيمَ، التَّيْمِيِّ عَنْ أَبِيهِ، عَنْ أَبِي مَسْعُودٍ الأَنْصَارِيِّ، قَالَ كُنْتُ أَضْرِبُ غُلاَمًا لِي فَسَمِعْتُ مِنْ خَلْفِي صَوْتًا ‏"‏ اعْلَمْ أَبَا مَسْعُودٍ لَلَّهُ أَقْدَرُ عَلَيْكَ مِنْكَ عَلَيْهِ ‏"‏ ‏.‏ فَالْتَفَتُّ فَإِذَا هُوَ رَسُولُ اللَّهِ صلى الله عليه وسلم فَقُلْتُ يَا رَسُولَ اللَّهِ هُوَ حُرٌّ لِوَجْهِ اللَّهِ ‏.‏ فَقَالَ ‏"‏ أَمَا لَوْ لَمْ تَفْعَلْ لَلَفَحَتْكَ النَّارُ أَوْ لَمَسَّتْكَ النَّارُ ‏"‏ ‏.‏
Reference : Sahih Muslim 1659c
In-book reference : Book 27, Hadith 55
USC-MSA web (English) reference : Book 15, Hadith 4088
  (deprecated numbering scheme)