Ali had stayed behind from the Prophet ﷺ during the expedition to Khaybar because he was suffering from an eye ailment. He said, "Shall I stay behind from the Messenger of Allah ﷺ?" So Ali set out and caught up with the Prophet ﷺ.On the eve of the day Allah granted the conquest, the Messenger of Allah ﷺ said, "Tomorrow I will surely give the banner to a man whom Allah and His Messenger love," or he said, "who loves Allah and His Messenger. Allah will grant victory through him."Then suddenly there was Ali, though we had not expected him. The people said, "Here is Ali." So the Messenger of Allah ﷺ gave him the banner, and Allah granted him victory.
حدثنا قتيبة بن سعيد حدثنا حاتم يعني ابن إسمعيل عن يزيد بن أبي عبيد
كان علي قد تخلف عن النبي ﷺ في خيبر وكان رمدا فقال أنا أتخلف عن رسول الله ﷺ فخرج علي فلحق بالنبي ﷺ فلما كان مساء الليلة التي فتحها الله في صباحها قال رسول الله ﷺ لأعطين الراية أو ليأخذن بالراية غدا رجل يحبه الله ورسوله أو قال يحب الله ورسوله يفتح الله عليه فإذا نحن بعلي وما نرجوه فقالوا هذا علي فأعطاه رسول الله ﷺ الراية ففتح الله عليه