Abdullah bin Umar reported,

Muhammad bin al-Sabbah and Suwayd bin Saeed narrated to us, both saying that Abdullah bin Raja al-Makki narrated to them from Ubaydullah, from Nafi, from Ibn Umar, that the Messenger of Allah ﷺ said, "It is the duty of a Muslim to listen and obey, whether he likes it or dislikes it, unless he is commanded to commit a sin. If he is commanded to commit a sin, then there is no listening and no obeying."

Ibn Majah 2864

Sahih

حدثنا محمد بن رمح أنبأنا الليث بن سعد عن عبيد الله بن عمر عن نافع

عن ابن عمر

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

ابن ماجه 2864صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Ibn Majah
Book
Jihad
Chapter
No obedience in disobedience to Allah
Numbering
Darussalam 2864
Ibn Majah 2864