Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bukhari:4714ʿAmr b. ʿAlī > Yaḥyá > Sufyān > Sulaymān > Ibrāhīm > Abū Maʿmar > ʿAbdullāh > Rabbihim al-Wasīlah

Regarding the explanation of the Verse: 'Those whom they call upon (worship) (like Jesus the Son of Mary, angels etc.) desire (for themselves) means of access to their Lord (Allah) as to which of them should be the nearer and they hope for His Mercy and fear His torment.' (17.57) They themselves (e.g. Angels, saints, Apostles, Jesus, etc.,) worshipped Allah, Those Jinns who were worshipped by some Arabs became Muslims (embraced Islam), but those human beings stuck to their (old) religion. Al- Aʿmash said extra: 'Say, (O Muhammad): Call unto those besides Him whom you assume (to be gods).' (17.56)  

البخاري:٤٧١٤حَدَّثَنِي عَمْرُو بْنُ عَلِيٍّ حَدَّثَنَا يَحْيَى حَدَّثَنَا سُفْيَانُ حَدَّثَنِي سُلَيْمَانُ عَنْ إِبْرَاهِيمَ عَنْ أَبِي مَعْمَرٍ عَنْ عَبْدِ اللَّهِ {إِلَى رَبِّهِمِ الْوَسِيلَةَ} قَالَ

كَانَ نَاسٌ مِنَ الإِنْسِ يَعْبُدُونَ نَاسًا مِنَ الْجِنِّ فَأَسْلَمَ الْجِنُّ وَتَمَسَّكَ هَؤُلاَءِ بِدِينِهِمْ زَادَ الأَشْجَعِيُّ عَنْ سُفْيَانَ عَنِ الأَعْمَشِ {قُلِ ادْعُوا الَّذِينَ زَعَمْتُمْ}  


See similar narrations below:

Collected by Nasāʾī's Kubrá

قَوْلُهُ تَعَالَى: {أُولَئِكَ الَّذِينَ يَدْعُونَ يَبْتَغُونَ إِلَى رَبِّهِمُ الْوَسِيلَةَ} [الإسراء: 57]

nasai-kubra:11225ʿAmr b. ʿAlī > Yaḥyá > Sufyān > Sulaymān > Ibrāhīm > Abū Maʿmar

[Machine] From Abdullah, regarding his saying, "Those are the ones who invoke, seeking means to their Lord." [17:57]. He said, "There were people among mankind who worshipped the jinn. Then the jinn embraced Islam and these people adhered to their religion."  

الكبرى للنسائي:١١٢٢٥أَخْبَرَنَا عَمْرُو بْنُ عَلِيٍّ حَدَّثَنَا يَحْيَى قَالَ حَدَّثَنَا سُفْيَانُ قَالَ أَنْبَأَنِي سُلَيْمَانُ عَنْ إِبْرَاهِيمَ عَنْ أَبِي مَعْمَرٍ

عَنْ عَبْدِ اللهِ فِي قَوْلِهِ {أُولَئِكَ الَّذِينَ يَدْعُونَ يَبْتَغُونَ إِلَى رَبِّهِمُ الْوَسِيلَةَ} [الإسراء 57] قَالَ «كَانَ نَاسٌ مِنَ الْإِنْسِ يَعْبُدُونَ نَاسًا مِنَ الْجِنِّ فَأَسْلَمَ الْجِنُّ وَتَمَسَّكَ هَؤُلَاءِ بِدِينِهِمْ»