The Messenger of Allah ﷺ sent out an army and placed a man in command over them, instructing the soldiers to listen to him and obey. The commander kindled a fire and ordered them to plunge into it. Some of them refused to enter, saying, "We only fled from the Fire to follow the Prophet." Others were ready to enter it.When news of this reached the Prophet ﷺ, he said, "Had they entered it, they would have remained in it forever." Then he said, "There is no obedience in disobedience to Allah. Obedience is only in what is right."
حدثنا عمرو بن مرزوق أخبرنا شعبة عن زبيد عن سعد بن عبيدة عن أبي عبد الرحمن السلمي
أن رسول الله ﷺ بعث جيشا وأمر عليهم رجلا وأمرهم أن يسمعوا له ويطيعوا فأجج نارا وأمرهم أن يقتحموا فيها فأبى قوم أن يدخلوها وقالوا إنما فررنا من النار وأراد قوم أن يدخلوها فبلغ ذلك النبي ﷺ فقال لو دخلوها أو دخلوا فيها لم يزالوا فيها وقال لا طاعة في معصية الله إنما الطاعة في المعروف
Bukhari narrated it in Akhbar al-Ahad, chapter: What has been said regarding accepting the report of a single trustworthy narrator, etc., no. 7257, and Muslim in al-Imarah, chapter: The obligation of obeying rulers except in disobedience, etc., no. 1840, from the hadith of Shubah, through this same chain.