Abu Hurairah (May Allah be pleased with him) reported:
On the day of the battle of Khaibar, Messenger of Allah (ﷺ) said, "I shall hand over this banner to one who loves Allah and His Messenger, and Allah will give us victory through him." 'Umar (May Allah be pleased with him) said: "I had never longed for leadership but that day I expected that I might be called for. However, Messenger of Allah (ﷺ) called 'Ali bin Abu Talib (May Allah be pleased with him) and handed the banner to him and said, "Go forth and do not turn around till Allah bestows victory upon you". (On hearing this) 'Ali proceeded a little and then halted and without turning around inquired in a loud voice: "O Messenger of Allah, for what shall I fight them?" He (ﷺ) replied, "Go on fighting till they affirm that none has the right to be worshiped but Allah and that Muhammad is the Messenger of Allah. If they admit that, their lives and their properties will be secured, subject to their obligations according to Islam, and they will be answerable to Allah".[Muslim].
Arabic/English book reference: Book 1, Hadith 94