Salama reported,

Ali had stayed behind from the Prophet ﷺ during the expedition to Khaybar because he was suffering from an eye ailment. He said, "Am I to stay behind from the Messenger of Allah ﷺ?" So Ali set out and caught up with the Prophet ﷺ.On the evening before the morning in which Allah granted the victory, the Messenger of Allah ﷺ said, "Tomorrow I will surely give the banner," or he said, "the banner will surely be taken by 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 been expecting him. The people said, "This is Ali." So the Messenger of Allah ﷺ gave him the banner, and Allah granted victory through him.

Bukhari 3702

Sahih

حدثنا قتيبة حدثنا حاتم عن يزيد بن أبي عبيد

عن سلمة قال

كان علي قد تخلف عن النبي ﷺ في خيبر وكان به رمد فقال أنا أتخلف عن رسول الله ﷺ فخرج علي فلحق بالنبي ﷺ فلما كان مساء الليلة التي فتحها الله في صباحها قال رسول الله ﷺ لأعطين الراية أو ليأخذن الراية غدا رجلا يحبه الله ورسوله أو قال يحب الله ورسوله يفتح الله عليه فإذا نحن بعلي وما نرجوه فقالوا هذا علي فأعطاه رسول الله ﷺ الراية ففتح الله عليه

البخاري 3702صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Virtues of the companions of the Prophet ﷺ
Chapter
Virtues of Ali bin Abu Talib Qurashi Hashimi, Abu Hasan, may Allah be pleased with him
Numbering
Darussalam 3702
Bukhari 3702