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:15795Abū ʿAlī al-Rūdhbārī > Abū Bakr b. Dāsah > Abū Dāwud > Muḥammad b. al-ʿAlāʾ And Ibn al-Muthanná > Abū Muʿāwiyah > al-Aʿmash > Ibrāhīm al-Taymī from his father > Abū Masʿūd al-Anṣārī

when I was beating a servant of mine, I heard a voice behind me saying: know, Abu Mas’ud-Ibn al-Muthanna said: “twice”-that Allah has more power over you than you have over him. I turned round and saw that it was that it was the prophet (May peace be upon him). I said : Messenger of Allah! He is free for Allah’s sake. He said : If you had not done it, fire would have burned you or the fire would have touched you. (Using translation from Abū Dāʾūd 5159)   

البيهقي:١٥٧٩٥أَخْبَرَنَا أَبُو عَلِيٍّ الرُّوذْبَارِيُّ أنبأ أَبُو بَكْرِ بْنُ دَاسَةَ ثنا أَبُو دَاوُدَ ثنا مُحَمَّدُ بْنُ الْعَلَاءِ وَابْنُ الْمُثَنَّى قَالَا ثنا أَبُو مُعَاوِيَةَ عَنِ الْأَعْمَشِ عَنْ إِبْرَاهِيمَ التَّيْمِيِّ عَنْ أَبِيهِ عَنْ أَبِي مَسْعُودٍ الْأَنْصَارِيِّ قَالَ كُنْتُ أَضْرِبُ غُلَامًا لِي

فَسَمِعْتُ مِنْ خَلْفِي صَوْتًا اعْلَمْ أَبَا مَسْعُودٍ اعْلَمْ أَبَا مَسْعُودٍ اعْلَمْ أَبَا مَسْعُودٍ لَلَّهُ أَقْدَرُ عَلَيْكَ مِنْكَ عَلَيْهِ فَالْتَفَتُ فَإِذَا هُوَ النَّبِيُّ ﷺ فَقُلْتُ يَا رَسُولَ اللهِ هُوَ حُرٌّ لِوَجْهِ اللهِ قَالَ أَمَا لَوْ لَمْ تَفْعَلْ لَلَفَعَتْكَ النَّارُ أَوْ لَمَسَّتْكَ النَّارُ  

رَوَاهُ مُسْلِمٌ فِي الصَّحِيحِ عَنْ مُحَمَّدِ بْنِ الْعَلَاءِ بْنِ أَبِي كُرَيْبٍ

See similar narrations below:

Collected by Muslim, Abū Dāwūd
muslim:1659cAbū Kurayb Muḥammad b. al-ʿAlāʾ > Abū Muʿāwiyah > al-Aʿmash > Ibrāhīm al-Taymī from his father > Abū Masʿūd al-Anṣārī

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 Messenger of Allah ﷺ. I said: Messenger of Allah, 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.  

مسلم:١٦٥٩cوَحَدَّثَنَا أَبُو كُرَيْبٍ مُحَمَّدُ بْنُ الْعَلاَءِ حَدَّثَنَا أَبُو مُعَاوِيَةَ حَدَّثَنَا الأَعْمَشُ عَنْ إِبْرَاهِيمَ التَّيْمِيِّ عَنْ أَبِيهِ عَنْ أَبِي مَسْعُودٍ الأَنْصَارِيِّ قَالَ كُنْتُ أَضْرِبُ غُلاَمًا لِي

فَسَمِعْتُ مِنْ خَلْفِي صَوْتًا اعْلَمْ أَبَا مَسْعُودٍ لَلَّهُ أَقْدَرُ عَلَيْكَ مِنْكَ عَلَيْهِ فَالْتَفَتُّ فَإِذَا هُوَ رَسُولُ اللَّهِ ﷺ فَقُلْتُ يَا رَسُولَ اللَّهِ هُوَ حُرٌّ لِوَجْهِ اللَّهِ فَقَالَ أَمَا لَوْ لَمْ تَفْعَلْ لَلَفَحَتْكَ النَّارُ أَوْ لَمَسَّتْكَ النَّارُ  

abudawud:5159[Chain 1] Muḥammad b. al-ʿAlāʾ > Abū Muʿāwiyah [Chain 2] Ibn al-Muthanná > Abū Muʿāwiyah > al-Aʿmash > Ibrāhīm al-Taymī from his father > Abū Masʿūd al-Anṣārī

when I was beating a servant of mine, I heard a voice behind me saying: know, Abu Mas’ud-Ibn al-Muthanna said: “twice”-that Allah has more power over you than you have over him. I turned round and saw that it was that it was the prophet (May peace be upon him). I said : Messenger of Allah! He is free for Allah’s sake. He said : If you had not done it, fire would have burned you or the fire would have touched you.  

أبو داود:٥١٥٩حَدَّثَنَا مُحَمَّدُ بْنُ الْعَلاَءِ قَالَ حَدَّثَنَا أَبُو مُعَاوِيَةَ ح وَحَدَّثَنَا ابْنُ الْمُثَنَّى قَالَ حَدَّثَنَا أَبُو مُعَاوِيَةَ عَنِ الأَعْمَشِ عَنْ إِبْرَاهِيمَ التَّيْمِيِّ عَنْ أَبِيهِ عَنْ أَبِي مَسْعُودٍ الأَنْصَارِيِّ قَالَ كُنْتُ أَضْرِبُ غُلاَمًا لِي

فَسَمِعْتُ مِنْ خَلْفِي صَوْتًا اعْلَمْ أَبَا مَسْعُودٍ قَالَ ابْنُ الْمُثَنَّى مَرَّتَيْنِ لَلَّهُ أَقْدَرُ عَلَيْكَ مِنْكَ عَلَيْهِ فَالْتَفَتُّ فَإِذَا هُوَ النَّبِيُّ ﷺ فَقُلْتُ يَا رَسُولَ اللَّهِ هُوَ حُرٌّ لِوَجْهِ اللَّهِ قَالَ أَمَا إِنَّكَ لَوْ لَمْ تَفْعَلْ لَلَفَعَتْكَ النَّارُ أَوْ لَمَسَّتْكَ النَّارُ