كتاب الجهاد والسير
32  
The Book of Jihad and Expeditions
(6)
Chapter: It is disliked to wish to meet the enemy, and the command to be steadfast when meeting the enemy
(6)
باب كَرَاهَةِ تَمَنِّي لِقَاءِ الْعَدُوِّ وَالأَمْرِ بِالصَّبْرِ عِنْدَ اللِّقَاءِ ‏‏
Sahih Muslim 1742 a

It is narrated by Abu Nadr that he learnt from a letter sent by a man from the Aslam tribe, who was a Companion of the Prophet (ﷺ) and whose name was 'Abdullah b. Abu Aufa, to 'Umar b. 'Ubaidullah when the latter marched upon Haruriyya (Khawarij) informing him that the Messenger of Allah (ﷺ) in one of those days when lie was confronting the enemy waited until the sun had declined. Then he stood up (to address the people) and said:

O ye men, do not wish for an encounter with the enemy. Pray to Allah to grant you security; (but) when you (have to) encounter them exercise patience, and you should know that Paradise is under the shadows of the swords. Then the Messenger of Allah (ﷺ) stood up (again) and said: O Allah. Revealer of the Book, Disperser of the clouds, Defeater of the hordes, put our enemy to rout and help us against them.
وَحَدَّثَنِي مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا ابْنُ جُرَيْجٍ، أَخْبَرَنِي مُوسَى، بْنُ عُقْبَةَ عَنْ أَبِي النَّضْرِ، عَنْ كِتَابِ، رَجُلٍ مِنْ أَسْلَمَ مِنْ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم يُقَالُ لَهُ عَبْدُ اللَّهِ بْنُ أَبِي أَوْفَى فَكَتَبَ إِلَى عُمَرَ بْنِ عُبَيْدِ اللَّهِ حِينَ سَارَ إِلَى الْحَرُورِيَّةِ يُخْبِرُهُ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم كَانَ فِي بَعْضِ أَيَّامِهِ الَّتِي لَقِيَ فِيهَا الْعَدُوَّ يَنْتَظِرُ حَتَّى إِذَا مَالَتِ الشَّمْسُ قَامَ فِيهِمْ فَقَالَ ‏"‏ يَا أَيُّهَا النَّاسُ لاَ تَتَمَنَّوْا لِقَاءَ الْعَدُوِّ وَاسْأَلُوا اللَّهَ الْعَافِيَةَ فَإِذَا لَقِيتُمُوهُمْ فَاصْبِرُوا وَاعْلَمُوا أَنَّ الْجَنَّةَ تَحْتَ ظِلاَلِ السُّيُوفِ ‏"‏ ‏.‏ ثُمَّ قَامَ النَّبِيُّ صلى الله عليه وسلم وَقَالَ ‏"‏ اللَّهُمَّ مُنْزِلَ الْكِتَابِ وَمُجْرِيَ السَّحَابِ وَهَازِمَ الأَحْزَابِ اهْزِمْهُمْ وَانْصُرْنَا عَلَيْهِمْ ‏"‏ ‏.‏
Reference : Sahih Muslim 1742a
In-book reference : Book 32, Hadith 23
USC-MSA web (English) reference : Book 19, Hadith 4314
  (deprecated numbering scheme)