Mishkat al-Masabih 3353
Abu Mas'ud al-Ansari said:
When I was beatinig a servant of mine I heard a voice behind me saying, “Know, Abu Mas'ud, that God has more power over you than you have over him.” On turning round and seeing that it was God’s Messenger, I said, “Messenger of God, he is free for God’s sake.” He replied, “If you had not done it the fire would have burned you,” or, “the fire would have touched you.” 

Muslim transmitted it.
وَعَنْ أَبِي مَسْعُودٍ الْأَنْصَارِيِّ قَالَ: كُنْتُ أَضْرِبُ غُلَامًا لِي فَسَمِعْتُ مِنْ خَلْفِي صَوْتًا: «اعْلَمْ أَبَا مَسْعُودٍ لَلَّهُ أَقْدَرُ عَلَيْكَ مِنْكَ عَلَيْهِ» فَالْتَفَتُّ فَإِذَا هُوَ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ فَقُلْتُ: يَا رَسُولَ اللَّهِ هُوَ حُرٌّ لِوَجْهِ اللَّهِ فَقَالَ: «أَمَا لَوْ لَمْ تَفْعَلْ لَلَفَحَتْكَ النَّارُ أَوْ لَمَسَّتْكَ النَّارُ» . رَوَاهُ مُسلم