Sahih al-Bukhari, Hadith 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).

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدٍ، حَدَّثَنَا سُفْيَانُ، عَنْ عَمْرٍو، سَمِعَ جَابِرًا، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ ـ رضى الله عنهم ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ ‏ "‏ يَأْتِي زَمَانٌ يَغْزُو فِئَامٌ مِنَ النَّاسِ، فَيُقَالُ فِيكُمْ مَنْ صَحِبَ النَّبِيَّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ عَلَيْهِ، ثُمَّ يَأْتِي زَمَانٌ فَيُقَالُ فِيكُمْ مَنْ صَحِبَ أَصْحَابَ النَّبِيِّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ، ثُمَّ يَأْتِي زَمَانٌ فَيُقَالُ فِيكُمْ مَنْ صَحِبَ صَاحِبَ أَصْحَابِ النَّبِيِّ صلى الله عليه وسلم فَيُقَالُ نَعَمْ‏.‏ فَيُفْتَحُ ‏" ‏‏.‏

sunnah.com