It is narrated from Sayyiduna Ali (may Allah be pleased with him) that a group of Quraysh came to him, and he said: "Shall I not tell you something about Abu al-Qasim (peace and blessings be upon him)?" They said: Yes, certainly! He related: "Three days before the death of the Messenger of Allah (peace and blessings be upon him), Allah Almighty sent Jibril (peace be upon him) down to him, and he said: O Ahmad! Allah Almighty has sent me to you to honour you, to show you favour and to grant you a special distinction. I ask you about that which He knows better than you; He asks: How do you find yourself? He (peace and blessings be upon him) said: 'O Jibril, I find myself in distress.' Then Jibril (peace be upon him) came on the second day and said the same, then he came on the third day and repeated the same thing, and he (peace and blessings be upon him) added: 'And O Jibril, I find myself grieved and heavy-hearted.' The narrator said: On this occasion an angel called Isma'il descended through the air along with Jibril (peace be upon him); he was in charge of seventy thousand angels. Jibril (peace be upon him) said: O Ahmad! This is the Angel of Death, asking your permission to enter. He has never asked permission of any human being before you, nor will he ever ask permission of any human being after you. He (peace and blessings be upon him) said: 'Give him permission.' So Jibril (peace be upon him) gave him permission. The Angel of Death said: O Ahmad! Allah, the Mighty and Majestic, has sent me to you and has commanded me to obey you; if you command me to take your soul, I will take it, and if you dislike it, I will leave it. Then Jibril (peace be upon him) said: Indeed Allah Almighty longs to meet you. He (peace and blessings be upon him) said: 'O Angel of Death! Carry out what you have been commanded.' At this Jibril (peace be upon him) said: O Ahmad! Peace be upon you. This is my last step upon the earth; you alone were my purpose in the world. Then, when the Messenger of Allah (peace and blessings be upon him) passed away and people came to offer condolences, they heard the voice of someone coming whose presence could be sensed but whose person could not be seen. He said: 'Peace be upon you and the mercy of Allah. Truly in Allah there is consolation for every calamity, a replacement for everyone who perishes, and recompense for everything that is lost. So put your trust in Allah alone and place your hope in Him, for the truly deprived one is he who is deprived of the reward, and the truly afflicted one is he who is deprived of the reward. And peace be upon you.'" Sayyiduna Ali (may Allah be pleased with him) asked: "Do you know who this was? This was al-Khidr (peace be upon him)."
Imam al-Shafi'i narrated it among the reports that Imam al-Tahawi heard from him, through Imam al-Muzani from Imam al-Shafi'i, from al-Qasim bin Abdullah bin Umar bin Hafs, from Ja'far bin Muhammad, from his father, that some men of Quraysh came to his father Ali bin al-Husayn, and he said: "Shall I not tell you about the Messenger of Allah (peace and blessings be upon him)?" They said: Yes. Then he mentioned the whole hadith, except that in it are the words: "The name of this angel is Isma'il, who is in charge of a hundred thousand angels, and each of these angels is in charge of a further hundred thousand angels." In it there is also that when the Angel of Death said "I will leave it," he (peace and blessings be upon him) asked: "O Angel of Death! Will you really do that?" He said: Yes, this is what I have been commanded, and I have also been commanded to obey you. The narrator said: Then he (peace and blessings be upon him) looked at Jibril (peace be upon him), and Jibril (peace be upon him) said: O Muhammad! Then he mentioned something similar. And in this narration, after the word "reward," it says that Sayyiduna Ali (may Allah be pleased with him) said: "Do you know who this is? This is al-Khidr (peace be upon him)."
Hadith Referenceالمطالب العالية بزوائد المسانيد الثمانية / كتاب السيرة والمغازي / 4326
Hadith Takhrij«حکم الحدیث المطالب العالیہ محققاً تنسیق د. سعد بن ناصر بن عبد العزيز الشَّثري- مکتبہ شاملہ :الحديث بهذا الإِسناد فيه علتان: 1 - محمد بن جعفر الصادق، تكلم فيه ولم يترك. = = 2 - الانقطاع، فعلي بن الحسين بن علي بن أبي طالب لم يدرك عليًا رضي الله عنه. » «أخرجه المعجم الكبير للطبراني برقم: 2890، وأخرجه مجمع الزوائد ومنبع الفوائد برقم: 14260، 14261، وأخرجه مسند الإمام الشافعي برقم: 603، وأخرجه معرفة السنن والآثار برقم: 7759، وأخرجه إتحاف الخيرة المهرة بزوائد المسانيد العشرة برقم: 2037»