Language:
كتاب الرقاق
81  
To make the Heart Tender (Ar-Riqaq)
(41)
Chapter: Whoever loves to meet Allah, Allah loves to meet him
(41)
باب ‏"‏ مَنْ أَحَبَّ لِقَاءَ اللَّهِ أَحَبَّ اللَّهُ لِقَاءَهُ ‏"‏
Sahih al-Bukhari 6509

Narrated `Aisha:

(the wife of the Prophet) When Allah's Messenger (ﷺ) was in good health, he used to say, "No prophet's soul is ever captured unless he is shown his place in Paradise and given the option (to die or survive)." So when the death of the Prophet (ﷺ) approached and his head was on my thigh, he became unconscious for a while and then he came to his senses and fixed his eyes on the ceiling and said, "O Allah (with) the highest companions." (See Qur'an 4:69). I said' "Hence he is not going to choose us." And I came to know that it was the application of the narration which he (the Prophet) used to narrate to us. And that was the last statement of the Prophet (before his death) i.e., "O Allah! With the highest companions." (See Qur'an 4:69)

حَدَّثَنِي يَحْيَى بْنُ بُكَيْرٍ، حَدَّثَنَا اللَّيْثُ، عَنْ عُقَيْلٍ، عَنِ ابْنِ شِهَابٍ، أَخْبَرَنِي سَعِيدُ بْنُ الْمُسَيَّبِ، وَعُرْوَةُ بْنُ الزُّبَيْرِ، فِي رِجَالٍ مِنْ أَهْلِ الْعِلْمِ أَنَّ عَائِشَةَ زَوْجَ النَّبِيِّ صلى الله عليه وسلم قَالَتْ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم يَقُولُ وَهْوَ صَحِيحٌ ‏"‏ إِنَّهُ لَمْ يُقْبَضْ نَبِيٌّ قَطُّ حَتَّى يَرَى مَقْعَدَهُ مِنَ الْجَنَّةِ ثُمَّ يُخَيَّرُ ‏"‏‏.‏ فَلَمَّا نَزَلَ بِهِ، وَرَأْسُهُ عَلَى فَخِذِي، غُشِيَ عَلَيْهِ سَاعَةً، ثُمَّ أَفَاقَ، فَأَشْخَصَ بَصَرَهُ إِلَى السَّقْفِ ثُمَّ قَالَ ‏"‏ اللَّهُمَّ الرَّفِيقَ الأَعْلَى ‏"‏‏.‏ قُلْتُ إِذًا لاَ يَخْتَارُنَا، وَعَرَفْتُ أَنَّهُ الْحَدِيثُ الَّذِي كَانَ يُحَدِّثُنَا بِهِ ـ قَالَتْ ـ فَكَانَتْ تِلْكَ آخِرَ كَلِمَةٍ تَكَلَّمَ بِهَا النَّبِيُّ صلى الله عليه وسلم قَوْلُهُ ‏"‏ اللَّهُمَّ الرَّفِيقَ الأَعْلَى ‏"‏‏.‏
Reference : Sahih al-Bukhari 6509
In-book reference : Book 81, Hadith 98
USC-MSA web (English) reference : Vol. 8, Book 76, Hadith 516
  (deprecated numbering scheme)