كتاب المغازى
64  
Military Expeditions led by the Prophet (pbuh) (Al-Maghaazi)
(83)
Chapter: The sickness of the Prophet (saws) and his death
(83)
بَابُ مَرَضِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَوَفَاتِهِ
Sahih al-Bukhari 4436

Narrated `Aisha:

When the Prophet (ﷺ) fell ill in his fatal illness, he started saying, "With the highest companion."

حَدَّثَنَا مُسْلِمٌ، حَدَّثَنَا شُعْبَةُ، عَنْ سَعْدٍ، عَنْ عُرْوَةَ، عَنْ عَائِشَةَ، قَالَتْ لَمَّا مَرِضَ النَّبِيُّ صلى الله عليه وسلم الْمَرَضَ الَّذِي مَاتَ فِيهِ جَعَلَ يَقُولُ ‏ "‏ فِي الرَّفِيقِ الأَعْلَى ‏"‏‏.‏
Reference : Sahih al-Bukhari 4436
In-book reference : Book 64, Hadith 457
USC-MSA web (English) reference : Vol. 5, Book 59, Hadith 720
  (deprecated numbering scheme)