كتاب الجهاد والسير
32  
The Book of Jihad and Expeditions
(7)
Chapter: It is recommended to pray for victory when meeting the enemy
(7)
باب اسْتِحْبَابِ الدُّعَاءِ بِالنَّصْرِ عِنْدَ لِقَاءِ الْعَدُوِّ ‏‏
Sahih Muslim 1743

It is narrated on the authority of Anas that the Messenger of Allah (ﷺ) said on the day of the Battle of Uhud:

O Allah, if Thou wilt (defeat Muslims), there will be none on the earth to worship Thee.
وَحَدَّثَنِي حَجَّاجُ بْنُ الشَّاعِرِ، حَدَّثَنَا عَبْدُ الصَّمَدِ، حَدَّثَنَا حَمَّادٌ، عَنْ ثَابِتٍ، عَنْ أَنَسٍ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم كَانَ يَقُولُ يَوْمَ أُحُدٍ ‏ "‏ اللَّهُمَّ إِنَّكَ إِنْ تَشَأْ لاَ تُعْبَدْ فِي الأَرْضِ ‏"‏ ‏.‏
Reference : Sahih Muslim 1743
In-book reference : Book 32, Hadith 27
USC-MSA web (English) reference : Book 19, Hadith 4318
  (deprecated numbering scheme)