Sahih Muslim , Hadith 1840

It has been narrated on the authority of Abu 'Abd al-Rahman from 'Ali that the Messenger of Allah sent a force (on a mission) and appointed over them a man. He kindled a fire and said: Enter it. Some people made up their minds to enter it (the fire), (carrying out the order of their commander), but the others said: We fled from the fire (that's why we have come into the fold of Islam). The matter was reported to the Messenger of Allah. He said to those who Contemplated entering (the fire at the order of their commander): If you had entered it, you would have remained there until the Day of Judgment. He commanded the act of the latter group and said: There is no submission in matters involving God's disobedience or displeasure. Submission is obligatory only in what is good (and reasonable).

حَدَّثَنَا مُحَمَّدُ بْنُ الْمُثَنَّى، وَابْنُ، بَشَّارٍ - وَاللَّفْظُ لاِبْنِ الْمُثَنَّى - قَالاَ حَدَّثَنَا مُحَمَّدُ، بْنُ جَعْفَرٍ حَدَّثَنَا شُعْبَةُ، عَنْ زُبَيْدٍ، عَنْ سَعْدِ بْنِ عُبَيْدَةَ، عَنْ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ عَلِيٍّ، أَنَّعليه وسلم بَعَثَ جَيْشًا وَأَمَّرَ عَلَيْهِمْ رَجُلاً فَأَوْقَدَ نَارًا وَقَالَ ادْخُلُوهَا ‏.‏ فَأَرَادَ نَاسٌ أَنْ يَدْخُلُوهَا وَقَالَ الآخَرُونَ إِنَّا قَدْ فَرَرْنَا مِنْهَا ‏.‏ فَذُكِرَ ذَلِكَ لِرَسُولِ اللَّهِ صلى الله عليه وسلم فَقَالَ لِلَّذِينَ أَرَادُوا أَنْ يَدْخُلُوهَا ‏"‏ لَوْ دَخَلْتُمُوهَا لَمْ تَزَالُوا فِيهَا إِلَى يَوْمِ الْقِيَامَةِ ‏"‏ ‏.‏ وَقَالَ لِلآخَرِينَ قَوْلاً حَسَنًا وَقَالَ ‏"‏ لاَ طَاعَةَ فِي مَعْصِيَةِ اللَّهِ إِنَّمَا الطَّاعَةُ فِي الْمَعْرُوفِ ‏"‏ ‏.‏

sunnah.com

It has been narrated on the authority of 'All who said: The Mersenger of Allah sent an expeditionand appointed over the Mujahids a man from the Ansar. (While making the appointment), he ordered that his work should be listened to and obeyed. They made him angry in a matter. He said: Collect for me dry wood. They collected it for him. Then he said: Kindle a fire. They kindled (the fire). Then he said: Didn't the Messenger of Allah order you to listen to me and obey (my orders)? They said: Yes. He said: Enter the fire. The narrator says: (At this), they began to look at one another and said: We fled from the fire to (find refuge with) the Messenger of Allah (and now you order us to enter it). They stood quiet until his anger cooled down and the fire went out. When they returned, they related the incident to the Messenger of Allah. He said: If they had entered it, they would not have come out. Obedience (to the commander) is obligatory only in what is good.

وَحَدَّثَنَا مُحَمَّدُ بْنُ عَبْدِ اللَّهِ بْنِ نُمَيْرٍ، وَزُهَيْرُ بْنُ حَرْبٍ، وَأَبُو سَعِيدٍ الأَشَجُّ - وَتَقَارَبُوا فِي اللَّفْظِ - قَالُوا حَدَّثَنَا وَكِيعٌ، حَدَّثَنَا الأَعْمَشُ، عَنْ سَعْدِ بْنِ عُبَيْدَةَ، عَنْ أَبِي عَبْدِ الرَّحْمَنِ، عَنْ عَلِيٍّ، قَالَ بَعَثَ رَسُولُ اللَّهِ صلى الله عليه وسلم سَرِيَّةً وَاسْتَعْمَلَ عَلَيْهِمْ رَجُلاً مِنَ الأَنْصَارِ وَأَمَرَهُمْ أَنْ يَسْمَعُوا لَهُ وَيُطِيعُوا فَأَغْضَبُوهُ فِي شَىْءٍ فَقَالَ اجْمَعُوا لِي حَطَبًا ‏.‏ فَجَمَعُوا لَهُ ثُمَّ قَالَ أَوْقِدُوا نَارًا ‏.‏ فَأَوْقَدُوا ثُمَّ قَالَ أَلَمْ يَأْمُرْكُمْ رَسُولُ اللَّهِ صلى الله عليه وسلم أَنْ تَسْمَعُوا لِي وَتُطِيعُوا قَالُوا بَلَى ‏.‏ قَالَ فَادْخُلُوهَا ‏.‏ قَالَ فَنَظَرَ بَعْضُهُمْ إِلَى بَعْضٍ فَقَالُوا إِنَّمَا فَرَرْنَا إِلَى رَسُولِ اللَّهِ صلى الله عليه وسلم مِنَ النَّارِ ‏.‏ فَكَانُوا كَذَلِكَ وَسَكَنَ غَضَبُهُ وَطُفِئَتِ النَّارُ فَلَمَّا رَجَعُوا ذَكَرُوا ذَلِكَ لِلنَّبِيِّ صلى الله عليه وسلم فَقَالَ ‏ "‏ لَوْ دَخَلُوهَا مَا خَرَجُوا مِنْهَا إِنَّمَا الطَّاعَةُ فِي الْمَعْرُوفِ ‏" ‏ ‏.‏

sunnah.com

This hadith has been transmitted on the authority of A'mash.

وَحَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا وَكِيعٌ، وَأَبُو مُعَاوِيَةَ عَنِ الأَعْمَشِ، بِهَذَا الإِسْنَادِ نَحْوَهُ ‏.‏

sunnah.com