Abdullah bin Umar reported,

The Messenger of Allah ﷺ said, "A Muslim is required to listen and obey in what he likes and dislikes, unless he is commanded to commit a sin. If he is commanded to commit a sin, then there is no listening and no obedience."

Nasai 4211

Sahih

أخبرنا قتيبة قال حدثنا الليث عن عبيد الله بن أبي جعفر عن نافع

عن ابن عمر قال

قال رسول الله ﷺ على المرء المسلم السمع والطاعة فيما أحب وكره إلا أن يؤمر بمعصية فإذا أمر بمعصية فلا سمع ولا طاعة

النسائي 4211صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Pledge of allegiance
Chapter
Recompense for one who commands disobedience and is obeyed
Numbering
Darussalam 4211
Nasai 4211