Abu Hurairah reported,

The Messenger of Allah ﷺ said on the day of Khaybar, "I will surely give this banner to a man who loves Allah and His Messenger, and through whose hands Allah will grant victory."Umar bin Khattab said, "I never desired leadership except on that day."He continued, "I stretched myself up, hoping to be called for it."Then the Messenger of Allah ﷺ called Ali bin Abu Talib and handed it to him, saying, "Go forward, and do not look back until Allah grants you victory."Ali advanced a short distance, then stopped without turning around and called out, "Messenger of Allah, on what basis shall I fight the people?"He replied, "Fight them until they bear witness that there is no god but Allah and that Muhammad is the Messenger of Allah. If they do that, they have protected their blood and property from you, except for what is due by right, and their reckoning is with Allah."

Azami 9919

Sahih

عن أبي هريرة

أن رسول الله ﷺ قال يوم خيبر: لأعطين هذه الراية رجلا يحب الله ورسوله يفتح الله على يديه. قال عمر بن الخطاب: ما أحببت الإمارة إلا يومئذ. قال: فتساورت لها رجاء أن أدعى لها. قال: فدعا رسول الله ﷺ علي بن أبي طالب فأعطاه إياها، وقال: امش، ولا تلتفت حتى يفتح الله عليك. قال فسار علي شيئا، ثم وقف ولم يلتفت، فصرخ يا رسول الله على ماذا أقاتل الناس؟ قال: قاتلهم حتى يشهدوا أن لا إله إلا الله وأن محمدا رسول الله. فإذا فعلوا ذلك فقد منعوا منك دماءهم وأموالهم إلا بحقها وحسابهم على الله.

الأعظمي 9919صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Virtues of the Companions and reports about them
Chapter
Virtues and reports of Ali bin Abu Talib
Section
Prophet's ﷺ glad tidings that Allah would open Khaybar at the hands of Ali, and that Allah and His Messenger love him
Numbering
Jami al-Kamil 9919 (2nd edition)
Azami 9919