Ayesha reported,

The Prophet ﷺ used to say while he was in good health, "No prophet's soul is taken until he is shown his place in Paradise, and then he is given the choice."When the illness came upon him and his head was resting on my thigh, he lost consciousness for a while, then he regained his senses and fixed his gaze toward the ceiling of the room. Then he said, "O Allah, the highest companionship."I said to myself, "Then he is not choosing us." And I realized that this was the very thing he had been telling us about while he was healthy.She said, those were the last words he spoke, "O Allah, the highest companionship."

Bukhari 4463

Sahih

حدثنا بشر بن محمد حدثنا عبد الله قال يونس قال الزهري أخبرني سعيد بن المسيب في رجال من أهل العلم أن

عائشة قالت

كان النبي ﷺ يقول وهو صحيح إنه لم يقبض نبي حتى يرى مقعده من الجنة ثم يخير فلما نزل به ورأسه على فخذي غشي عليه ثم أفاق فأشخص بصره إلى سقف البيت ثم قال اللهم الرفيق الأعلى فقلت إذا لا يختارنا وعرفت أنه الحديث الذي كان يحدثنا وهو صحيح قالت فكانت آخر كلمة تكلم بها اللهم الرفيق الأعلى

البخاري 4463صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expeditions
Chapter
Last words the Prophet ﷺ spoke
Numbering
Darussalam 4463
Bukhari 4463