Abu Hurairah reported,

On the day of Khaybar, the Messenger of Allah ﷺ said, "I will surely give this banner to a man who loves Allah and His Messenger, through whose hands Allah will grant victory."Umar bin Khattab said, "I never desired leadership except on that day."He said, "I stretched up hoping to be called for it."He said, the Messenger of Allah ﷺ called Ali bin Abu Talib, gave the banner to him, and said, "Go forward and do not look back until Allah grants you victory."Ali went a short distance, then stopped without looking back 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 their wealth from you, except by its rightful claim, and their reckoning is with Allah."

Muslim 6222

Sahih

حدثنا قتيبة بن سعيد حدثنا يعقوب يعني ابن عبد الرحمن القاري عن سهيل عن أبيه

عن أبي هريرة

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

مسلم 6222صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Virtues of the Companions, may Allah be pleased with them
Chapter
From the virtues of Ali bin Abu Talib, may Allah be pleased with him
Numbering
Darussalam 6222
Muslim 6222