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

The same tradition has been transmitted by a different chain of narrators.

حَدَّثَنَا عَمْرُو بْنُ عَلِيٍّ، حَدَّثَنَا ابْنُ مَهْدِيٍّ، ح وَحَدَّثَنَا مُحَمَّدُ بْنُ عَمْرِو بْنِ جَبَلَةَ، حَدَّثَنَا بِشْرُ بْنُ عُمَرَ، قَالاَ جَمِيعًا حَدَّثَنَا هِشَامُ بْنُ سَعْدٍ، عَنْ زَيْدِ بْنِ أَسْلَمَ، عَنْ أَبِيهِ، عَنِ ابْنِ عُمَرَ، عَنِ النَّبِيِّ صلى الله عليه وسلم بِمَعْنَى حَدِيثِ نَافِعٍ عَنِ ابْنِ عُمَرَ ‏.‏
Reference : Sahih Muslim 1851c
In-book reference : Book 33, Hadith 92
USC-MSA web (English) reference : Book 20, Hadith 4564
  (deprecated numbering scheme)