كتاب الإمارة
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 1851 b

It has been narrated on the authority of Ibn 'Umar that he visited Ibn Muti', and related from the Prophet (ﷺ) the tradition that has gone before.

وَحَدَّثَنَا ابْنُ نُمَيْرٍ، حَدَّثَنَا يَحْيَى بْنُ عَبْدِ اللَّهِ بْنِ بُكَيْرٍ، حَدَّثَنَا لَيْثٌ، عَنْ عُبَيْدِ اللَّهِ، بْنِ أَبِي جَعْفَرٍ عَنْ بُكَيْرِ بْنِ عَبْدِ اللَّهِ بْنِ الأَشَجِّ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، أَنَّهُ أَتَى ابْنَ مُطِيعٍ ‏.‏ فَذَكَرَ عَنِ النَّبِيِّ صلى الله عليه وسلم نَحْوَهُ ‏.‏
Reference : Sahih Muslim 1851b
In-book reference : Book 33, Hadith 91
USC-MSA web (English) reference : Book 20, Hadith 4563
  (deprecated numbering scheme)