Language:
كتاب الإيمان
2  
Belief
(42)
Chapter: The statement of the Prophet (saws): Religion is An-Nasihah (to be sincere and true) to Allah, to His Messenger (Muhammad (saws)), to the Muslim rulers, and to all the Muslims
(42)
بَابُ قَوْلِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «الدِّينُ النَّصِيحَةُ لِلَّهِ وَلِرَسُولِهِ وَلأَئِمَّةِ الْمُسْلِمِينَ وَعَامَّتِهِمْ»
Sahih al-Bukhari 58

Narrated Ziyad bin'Ilaqa:

I heard Jarir bin 'Abdullah (Praising Allah). On the day when Al-Mughira bin Shu'ba died, he (Jarir) got up (on the pulpit) and thanked and praised Allah and said, "Be afraid of Allah alone Who has none along with Him to be worshipped.(You should) be calm and quiet till the (new) chief comes to you and he will come to you soon. Ask Allah's forgiveness for your (late) chief because he himself loved to forgive others." Jarir added, "Amma badu (now then), I went to the Prophet and said, 'I give my pledge of allegiance to you for Islam." The Prophet (ﷺ) conditioned (my pledge) for me to be sincere and true to every Muslim so I gave my pledge to him for this. By the Lord of this mosque! I am sincere and true to you (Muslims). Then Jarir asked for Allah's forgiveness and came down (from the pulpit).

حَدَّثَنَا أَبُو النُّعْمَانِ، قَالَ حَدَّثَنَا أَبُو عَوَانَةَ، عَنْ زِيَادِ بْنِ عِلاَقَةَ، قَالَ سَمِعْتُ جَرِيرَ بْنَ عَبْدِ اللَّهِ، يَقُولُ يَوْمَ مَاتَ الْمُغِيرَةُ بْنُ شُعْبَةَ قَامَ فَحَمِدَ اللَّهَ وَأَثْنَى عَلَيْهِ وَقَالَ عَلَيْكُمْ بِاتِّقَاءِ اللَّهِ وَحْدَهُ لاَ شَرِيكَ لَهُ، وَالْوَقَارِ وَالسَّكِينَةِ حَتَّى يَأْتِيَكُمْ أَمِيرٌ، فَإِنَّمَا يَأْتِيكُمُ الآنَ، ثُمَّ قَالَ اسْتَعْفُوا لأَمِيرِكُمْ، فَإِنَّهُ كَانَ يُحِبُّ الْعَفْوَ‏.‏ ثُمَّ قَالَ أَمَّا بَعْدُ، فَإِنِّي أَتَيْتُ النَّبِيَّ صلى الله عليه وسلم قُلْتُ أُبَايِعُكَ عَلَى الإِسْلاَمِ‏.‏ فَشَرَطَ عَلَىَّ وَالنُّصْحِ لِكُلِّ مُسْلِمٍ‏.‏ فَبَايَعْتُهُ عَلَى هَذَا، وَرَبِّ هَذَا الْمَسْجِدِ إِنِّي لَنَاصِحٌ لَكُمْ‏.‏ ثُمَّ اسْتَغْفَرَ وَنَزَلَ‏.‏
Reference : Sahih al-Bukhari 58
In-book reference : Book 2, Hadith 51
USC-MSA web (English) reference : Vol. 1, Book 2, Hadith 56
  (deprecated numbering scheme)