Hadithcore
Sahih Muslim, 2413 a
sahih

Sa'd reported:

This verse was revealed in relation to six persons and I and Ibn Mas'ud were amongst them. The polytheists said to him (the Prophet): Do not keep such persons near you. It was upon this that (this verse was revealed):" Drive not away those who call upon their Lord morning and evening desiring only His pleasure" (vi. 52).

حَدَّثَنَا زُهَيْرُ بْنُ حَرْبٍ، حَدَّثَنَا عَبْدُ الرَّحْمَنِ، عَنْ سُفْيَانَ، عَنِ الْمِقْدَامِ بْنِ شُرَيْحٍ، عَنْ أَبِيهِ، عَنْ سَعْدٍ، فِيَّ نَزَلَتْ ‏{‏ وَلاَ تَطْرُدِ الَّذِينَ يَدْعُونَ رَبَّهُمْ بِالْغَدَاةِ وَالْعَشِيِّ‏}‏ قَالَ نَزَلَتْ فِي سِتَّةٍ أَنَا وَابْنُ مَسْعُودٍ مِنْهُمْ وَكَانَ الْمُشْرِكُونَ قَالُوا لَهُ تُدْنِي هَؤُلاَءِ ‏.‏

References2 variants
In-Book Reference
Book 44, Hadith 70
USC-MSA web (English) reference
Book 31, Hadith 5935 (deprecated numbering scheme)