كتاب الإمارة
33  
The Book on Government
(13)
Chapter: The obligation of staying with the Jama'ah (main body) of the muslims when Fitn (tribulations) appear, and in all circumstances. The prohibition of refusing to obey and on splitting away from the Jama'ah
(13)
باب الأَمْرِ بِلُزُومِ الْجَمَاعَةِ عِنْدَ ظُهُورِ الْفِتَنِ وَتَحْذِيرِ الدُّعَاةِ إِلَى الْكُفْرِ ‏‏
Sahih Muslim 1847 b

It his been narrated through a different chain of transmitters, on the authority of Hudhaifa b. al-Yaman who said:

Messenger of Allah, no doubt, we had an evil time (i. e. the days of Jahiliyya or ignorance) and God brought us a good time (i. e. Islamic period) through which we are now living Will there be a bad time after this good time? He (the Holy Prophet) said: Yes. I said: Will there be a good time after this bad time? He said: Yes. I said: Will there be a bad time after good time? He said: Yes. I said: How? Whereupon he said: There will be leaders who will not be led by my guidance and who will not adopt my ways? There will be among them men who will have the hearts of devils in the bodies of human beings. I said: What should I do. Messenger of Allah, if I (happen) to live in that time? He replied: You will listen to the Amir and carry out his orders; even if your back is flogged and your wealth is snatched, you should listen and obey.
وَحَدَّثَنِي مُحَمَّدُ بْنُ سَهْلِ بْنِ عَسْكَرٍ التَّمِيمِيُّ، حَدَّثَنَا يَحْيَى بْنُ حَسَّانَ، ح وَحَدَّثَنَا عَبْدُ اللَّهِ بْنُ عَبْدِ الرَّحْمَنِ الدَّارِمِيُّ، أَخْبَرَنَا يَحْيَى، - وَهُوَ ابْنُ حَسَّانَ - حَدَّثَنَا مُعَاوِيَةُ، - يَعْنِي ابْنَ سَلاَّمٍ - حَدَّثَنَا زَيْدُ بْنُ سَلاَّمٍ، عَنْ أَبِي سَلاَّمٍ، قَالَ قَالَ حُذَيْفَةُ بْنُ الْيَمَانِ قُلْتُ يَا رَسُولَ اللَّهِ إِنَّا كُنَّا بِشَرٍّ فَجَاءَ اللَّهُ بِخَيْرٍ فَنَحْنُ فِيهِ فَهَلْ مِنْ وَرَاءِ هَذَا الْخَيْرِ شَرٌّ قَالَ نَعَمْ ‏.‏ قُلْتُ هَلْ وَرَاءَ ذَلِكَ الشَّرِّ خَيْرٌ قَالَ ‏"‏ نَعَمْ ‏"‏ ‏.‏ قُلْتُ فَهَلْ وَرَاءَ ذَلِكَ الْخَيْرِ شَرٌّ قَالَ ‏"‏ نَعَمْ ‏"‏ ‏.‏ قُلْتُ كَيْفَ قَالَ ‏"‏ يَكُونُ بَعْدِي أَئِمَّةٌ لاَ يَهْتَدُونَ بِهُدَاىَ وَلاَ يَسْتَنُّونَ بِسُنَّتِي وَسَيَقُومُ فِيهِمْ رِجَالٌ قُلُوبُهُمْ قُلُوبُ الشَّيَاطِينِ فِي جُثْمَانِ إِنْسٍ ‏"‏ ‏.‏ قَالَ قُلْتُ كَيْفَ أَصْنَعُ يَا رَسُولَ اللَّهِ إِنْ أَدْرَكْتُ ذَلِكَ قَالَ ‏"‏ تَسْمَعُ وَتُطِيعُ لِلأَمِيرِ وَإِنْ ضُرِبَ ظَهْرُكَ وَأُخِذَ مَالُكَ فَاسْمَعْ وَأَطِعْ ‏"‏ ‏.‏
Reference : Sahih Muslim 1847b
In-book reference : Book 33, Hadith 82
USC-MSA web (English) reference : Book 20, Hadith 4554
  (deprecated numbering scheme)