Abu Masud Uqba bin Amr reported,

I was beating a slave boy of mine when I heard a voice behind me saying, "Know, Abu Masud, that Allah has more power over you than you have over him."I turned around, and there was the Messenger of Allah ﷺ.I said, "Messenger of Allah, he is free for the sake of Allah."He said, "Had you not done so, the Fire would have scorched you," or, "the Fire would have touched you."

Muslim 4308

Sahih

و حدثنا أبو كريب محمد بن العلاء حدثنا أبو معاوية حدثنا الأعمش عن إبراهيم التيمي عن أبيه

عن أبي مسعود الأنصاري قال

كنت أضرب غلاما لي فسمعت من خلفي صوتا اعلم أبا مسعود لله أقدر عليك منك عليه فالتفت فإذا هو رسول الله ﷺ فقلت يا رسول الله هو حر لوجه الله فقال أما لو لم تفعل للفحتك النار أو لمستك النار

مسلم 4308صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Oaths
Chapter
Companionship with slaves and expiation for one who slaps his slave
Numbering
Darussalam 4308
Muslim 4308