As recorded in the Sahih, Ali—may Allah be pleased with him—(1) said:
“The Messenger of Allah—peace and blessings be upon him—dispatched a military detachment and appointed a man of the Ansar as its commander, instructing them to hear and obey him. They angered him over some matter, so he said, ‘Gather firewood for me.’ They gathered it. He then said, ‘Kindle a fire,’ and they kindled a fire (2). He then said, ‘Did the Messenger of Allah—peace and blessings be upon him—not command you to hear and obey me?’
“They replied, ‘Indeed.’
“He said, ‘Then enter it.’
“They looked at one another and said, ‘We fled from the Fire to the Messenger of Allah—peace and blessings be upon him.’ They remained so until his anger subsided and the fire went out. When they returned, they mentioned this to the Messenger of Allah—peace and blessings be upon him—and he said:
“‘Had they entered it, they would never have emerged from it. Obedience is required only in what is right.’” (3)
Another wording states:
“‘There is no obedience when it entails disobedience to Allah. Obedience is required only in what is right.’” (4)
Likewise, it is related in the two Sahihs (5) from Ibn Umar, from the Prophet—peace and blessings be upon him—