Sahih al-Bukhari, Book 64, Hadith 369 (In-Book) ⓘ
Narrated `Ali: The Prophet sent a Sariya under the command of a man from the Ansar and ordered the soldiers to obey him. He (i.e. the commander) became angry and said "Didn't the Prophet order you to obey me!" They replied, "Yes." He said, "Collect fire-wood for me." So they collected it. He said, "Make a fire." When they made it, he said, "Enter it (i.e. the fire)." So they intended to do that and started holding each other and saying, "We run towards (i.e. take refuge with) the Prophet from the fire." They kept on saying that till the fire was extinguished and the anger of the commander abated. When that news reached the Prophet he said, "If they had entered it (i.e. the fire), they would not have come out of it till the Day of Resurrection. Obedience (to somebody) is required when he enjoins what is good."
حَدَّثَنَا مُسَدَّدٌ، حَدَّثَنَا عَبْدُ الْوَاحِدِ، حَدَّثَنَا الأَعْمَشُ، قَالَ حَدَّثَنِي سَعْدُ بْنُ عُبَيْدَةَ، عَنْ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ عَلِيٍّ ـ رضى الله عنه ـ قَالَ بَعَثَ النَّبِيُّ صلى الله عليه وسلم سَرِيَّةً فَاسْتَعْمَلَ رَجُلاً مِنَ الأَنْصَارِ، وَأَمَرَهُمْ أَنْ يُطِيعُوهُ، فَغَضِبَ فَقَالَ أَلَيْسَ أَمَرَكُمُ النَّبِيُّ صلى الله عليه وسلم أَنْ تُطِيعُونِي. قَالُوا بَلَى. قَالَ فَاجْمَعُوا لِي حَطَبًا. فَجَمَعُوا، فَقَالَ أَوْقِدُوا نَارًا. فَأَوْقَدُوهَا، فَقَالَ ادْخُلُوهَا. فَهَمُّوا، وَجَعَلَ بَعْضُهُمْ يُمْسِكُ بَعْضًا، وَيَقُولُونَ فَرَرْنَا إِلَى النَّبِيِّ صلى الله عليه وسلم مِنَ النَّارِ. فَمَا زَالُوا حَتَّى خَمَدَتِ النَّارُ، فَسَكَنَ غَضَبُهُ، فَبَلَغَ النَّبِيَّ صلى الله عليه وسلم فَقَالَ " لَوْ دَخَلُوهَا مَا خَرَجُوا مِنْهَا إِلَى يَوْمِ الْقِيَامَةِ، الطَّاعَةُ فِي الْمَعْرُوفِ " .
also referenced under: Hadith 4340 (DarusSalam) & Volume 5, Book 59, Hadith 629 (USC-MSA)