كتاب التفسير
56  
The Book of Commentary on the Qur'an
(4)
Chapter: Allah's Saving: "Those Whom They Call Upon Desire Means Of Access To Their Lord (Allah)"
(4)
Sahih Muslim 3030 a

Abdullah b. Mas'ud reported in connection with the words of Allah, the Exalted and Glorious:

" Those to whom they call upon, themselves seek the means or access to their Lord as to whoever of them becomes nearest" (xvii. 57) that it related to a party of Jinn who were being worshipped and they embraced Islam but those who worshipped them kept on worshipping them (though the Jinn whom the misguided people worshipped had become Muslims). It was then that this verse was revealed.
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ إِدْرِيسَ، عَنِ الأَعْمَشِ، عَنْ إِبْرَاهِيمَ، عَنْ أَبِي مَعْمَرٍ، عَنْ عَبْدِ اللَّهِ، فِي قَوْلِهِ عَزَّ وَجَلَّ ‏{‏ أُولَئِكَ الَّذِينَ يَدْعُونَ يَبْتَغُونَ إِلَى رَبِّهِمُ الْوَسِيلَةَ أَيُّهُمْ أَقْرَبُ‏}‏ قَالَ كَانَ نَفَرٌ مِنَ الْجِنِّ أَسْلَمُوا وَكَانُوا يُعْبَدُونَ فَبَقِيَ الَّذِينَ كَانُوا يَعْبُدُونَ عَلَى عِبَادَتِهِمْ وَقَدْ أَسْلَمَ النَّفَرُ مِنَ الْجِنِّ ‏.‏
Reference : Sahih Muslim 3030a
In-book reference : Book 56, Hadith 32
USC-MSA web (English) reference : Book 43, Hadith 7182
  (deprecated numbering scheme)