Ali ﷺ had stayed behind from the Prophet ﷺ at Khaybar because he was suffering from an eye ailment. Then he said, "Am I to stay behind from the Messenger of Allah ﷺ?" So he set out and caught up with the Prophet ﷺ.On the evening of the night before the morning of its conquest, the Messenger of Allah ﷺ said, "Tomorrow I shall give the banner to a man," or he said, "the banner shall be taken tomorrow by a man whom Allah and His Messenger love," or he said, "who loves Allah and His Messenger. Allah will grant victory through him."Suddenly there was Ali, though we had not expected him. They said, "Here is Ali." So the Messenger of Allah ﷺ gave it to him, and Allah granted victory through him.
كان على ﷺ تخلف عن النبي ﷺ في خيبر، وكان به رمد، فقال: أنا أتخلف عن رسول الله ﷺ! فخرج على فلحق بالنبي ﷺ، فلما كان مساء الليلة التي فتحها في صباحها، فقال رسول الله ﷺ: لأعطين الراية- أو قال: ليأخذن. غدا رجل يحبه الله ورسوله. أو قال: يحب الله ورسوله. يفتح الله عليه، فإذا نحن بعلي وما نرجوه، فقالوا: هذا علي، فأعطاه رسول الله ﷺ، ففتح الله عليه.
Bukhari related it in the Book of jihad and Military Expeditions (2975), and Muslim related it in the Book of the Virtues of the Companions (2407:35), both of them from Qutayba bin Saeed, who said, Hatim bin Ismail narrated to us, from Yazid bin Abu Ubayd, from Salama bin Akwa, who said, and then he related it.