كتاب المقدمات
The Book of Miscellany
(80)
Chapter: Obligation of Obedience to the Ruler in what is Lawful and Prohibition of Obeying them in what is Unlawful
(80)
- باب وجوب طاعة ولاة الأمر في غير معصية وتحريم طاعتهم في المعصية
Riyad as-Salihin 664
Ibn 'Umar (May Allah be pleased with them) reported:
Messenger of Allah (ﷺ) said, "One who withdraws his hand from obedience (to the Amir) will find no argument (in his defense) when he stands before Allah on the Day of Resurrection; and one who dies without having sworn allegiance will die the death of one belonging to the Days of Ignorance."

[Muslim].

Another narration is: The Messenger of Allah (ﷺ) said, "He who dies having defected from obedience (to the Amir) and discards his association with the main body of the (Muslim) community, dies the death of one belonging to the Days of Jahiliyyah."

وعنه قال‏:‏ سمعت رسول الله صلى الله عليه وسلم يقول “من خلع يداً من طاعة لقي الله يوم القيامة ولا حجة له، ومن مات وليس في عنقه بيعة مات ميتة جاهلية” ‏(‏‏(‏رواه مسلم‏)‏‏)‏‏.‏
وفي رواية له‏:‏ “ومن مات وهو مفارق للجماعة، فإنه يموت ميتة جاهلية” ‏(‏‏(‏رواه مسلم‏)‏‏)‏‏.‏
وفي رواية له‏:‏ “ومن مات وهو مفارق للجماعة، فإنه يموت ميتة جاهلية”‏.‏
Reference : Riyad as-Salihin 664
In-book reference : Introduction, Hadith 664