Praise be to Allaah.
The last words of the Prophet (peace and blessings of Allaah be upon him) – before he bade farewell to this world – were: “O Allaah, (with) the higher companions”. This is the title that al-Bukhaari gave to a chapter in Kitaab al-Maghaazi in his Saheeh: “The last words of the Prophet (peace and blessings of Allaah be upon him)”, where he quoted the hadeeth of ‘Aa’ishah (may Allaah be pleased with her) who said: When the Prophet was healthy, he used to say, “No soul of a Prophet is taken until he has been shown his place in Paradise and then he is given the choice.” When death approached him while his head was on my thigh, he became unconscious and then recovered consciousness.
He then looked at the ceiling of the house and said, “O Allaah! (with) the highest companions." I said (to myself), “He is not going to choose (to stay with) us.” Then I understood what he meant when he said that to us when he was healthy. The last words he spoke were, "O Allaah! (with) the highest companions.”
Narrated by al-Bukhaari, 4463; Muslim, 2444.
There is a report narrated by Ahmad (1691) from the hadeeth of Abu ‘Ubaydah, who said that the last words that the Prophet (peace and blessings of Allaah be upon him) spoke were, “Expel the Jews of the Hijaaz and Najraan from the Arabian Peninsula, and know that the most evil of people are those who took the graves of their Prophets as places of worship.”