(4) باب السَّمْعِ وَالطَّاعَةِ لِلإِمَامِ مَا لَمْ تَكُنْ مَعْصِيَةً
Narrated `Ali:
The Prophet (ﷺ) sent an army unit (for some campaign) and appointed a man from the Ansar as its commander and ordered them (the soldiers) to obey him. (During the campaign) he became angry with them and said, "Didn't the Prophet (ﷺ) order you to obey me?" They said, "Yes." He said, "I order you to collect wood and make a fire and then throw yourselves into it." So they collected wood and made a fire, but when they were about to throw themselves into, it they started looking at each other, and some of them said, "We followed the Prophet (ﷺ) to escape from the fire. How should we enter it now?" So while they were in that state, the fire extinguished and their commander's anger abated. The event was mentioned to the Prophet (ﷺ) and he said, "If they had entered it (the fire) they would never have come out of it, for obedience is required only in what is good." (See Hadith No. 629. Vol. 5)
Reference: Sahih al-Bukhari 7145
In-book reference: Book 93, Hadith 9
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 9, Book 89, Hadith 259