The Messenger of Allah ﷺ said on the day of Khaybar, "I will surely give this banner to a man through whose hands Allah will grant victory. He loves Allah and His Messenger, and Allah and His Messenger love him."The people spent that night restless, wondering which of them would be given it. When morning came, they all went early to the Messenger of Allah ﷺ, each hoping to be the one given the banner.He asked, "Where is Ali bin Abu Talib?"They replied, "Messenger of Allah, he is suffering from a complaint in his eyes."So he called for him and prayed for him, and Ali was cured as though he had never had any pain at all. The hadith continues with the story of Khaybar.
أن رسول الله ﷺ قال يوم خيبر: لأعطين هذه الراية رجلا يفتح الله على يديه، يحب الله ورسوله، ويحبه الله ورسوله قال: فبات الناس يدوكون ليلتهم أيهم يعطاها، قال: فلما أصبح الناس غدوا على رسول الله ﷺ كلهم يرجون أن يعطاها فقال: أين علي بن أبي طالب؟ فقالوا: هو يا رسول الله يشتكي عينيه، فدعا له فبرأ حتى كأن لم يكن به وجع… الحديث في قصة خيبر.
Reported by Bukhari in the Book of Military Expeditions (4210) and Muslim in the Book of the Merits of the Companions (34:2406), both from Qutayba bin Saeed, who said, Yaqub bin Abdul-Rahman narrated to us, from Abu Hazim, Sahl bin Saad told me, and he related it.