Language:
كتاب الجهاد والسير
56  
Fighting for the Cause of Allah (Jihaad)
(76)
Chapter: The help of poor and pious men in war
(76)
باب مَنِ اسْتَعَانَ بِالضُّعَفَاءِ وَالصَّالِحِينَ فِي الْحَرْبِ
Sahih al-Bukhari 2897

Narrated Abu Sa`id Al-Khudri:

The Prophet (ﷺ) said, "A time will come when groups of people will go for Jihad and it will be asked, 'Is there anyone amongst you who has enjoyed the company of the Prophet?' The answer will be, 'Yes.' Then they will be given victory (by Allah) (because of him). Then a time will come when it will be asked. 'Is there anyone amongst you who has enjoyed the company of the companions of the Prophet?' It will be said, 'Yes,' and they will be given victory (by Allah). Then a time will come when it will be said. 'Is there anyone amongst you who has enjoyed the company of the companions of the companions of the Prophet?' It will be said, 'Yes,' and they will be given victory (by Allah).

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، حَدَّثَنَا سُفْيَانُ، عَنْ عَمْرٍو، سَمِعَ جَابِرًا، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ ـ رضى الله عنهم ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ يَأْتِي زَمَانٌ يَغْزُو فِئَامٌ مِنَ النَّاسِ، فَيُقَالُ فِيكُمْ مَنْ صَحِبَ النَّبِيَّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ عَلَيْهِ، ثُمَّ يَأْتِي زَمَانٌ فَيُقَالُ فِيكُمْ مَنْ صَحِبَ أَصْحَابَ النَّبِيِّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ، ثُمَّ يَأْتِي زَمَانٌ فَيُقَالُ فِيكُمْ مَنْ صَحِبَ صَاحِبَ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ ‏"‏‏.‏
Reference : Sahih al-Bukhari 2897
In-book reference : Book 56, Hadith 111
USC-MSA web (English) reference : Vol. 4, Book 52, Hadith 146
  (deprecated numbering scheme)