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. I stretched myself up hoping to be called for it."The Messenger of Allah ﷺ then called Ali bin Abu Talib and handed it to him, saying, "Go forward and do not turn back until Allah grants you victory."Ali advanced a little, 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 testify 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 by its right, and their reckoning is with Allah."

Azami 7861

Sahih

عن أبي هريرة

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

الأعظمي 7861صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Jihad
Chapter
Rulings on jihad and its etiquette
Section
Command to fight the warring enemies until they say, "There is no god but Allah"
Numbering
Jami al-Kamil 7861 (2nd edition)
Azami 7861