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.
hakim:2701Abū Bakr b. Isḥāq > Abū al-Muthanná > Musaddad > Yaḥyá b. Saʿīd > ʿUbaydullāh b. al-Akhnas > ʿAmr b. Shuʿayb from his father from his grandfather

[Machine] "I came to the Prophet ﷺ and said, 'O Messenger of Allah, can we marry slaves?' He remained silent, and then I recited the verse from the Quran: 'The adulterer does not marry except an adulteress or polytheist, and none marries her except an adulterer or a polytheist. And that has been made unlawful to the believers' (Quran 24:3). So the Messenger of Allah ﷺ read it to me and said, 'Do not marry her.'"  

الحاكم:٢٧٠١حَدَّثَنَا أَبُو بَكْرِ بْنُ إِسْحَاقَ أَنْبَأَ أَبُو الْمُثَنَّى ثنا مُسَدَّدٌ ثنا يَحْيَى بْنُ سَعِيدٍ حَدَّثَنِي عُبَيْدُ اللَّهِ بْنُ الْأَخْنَسِ عَنْ عَمْرِو بْنِ شُعَيْبٍ عَنْ أَبِيهِ عَنْ جَدِّهِ أَنَّ مَرْثَدَ بْنَ أَبِي مَرْثَدٍ الْغَنَوِيَّ كَانَ يَحْمِلُ الْأُسَارَى بِمَكَّةَ وَكَانَ بِمَكَّةَ بَغِيٌّ يُقَالُ لَهَا عَنَاقُ وَكَانَتْ صَدِيقَتَهُ قَالَ

فَجِئْتُ إِلَى النَّبِيِّ ﷺ فَقُلْتُ يَا رَسُولَ اللَّهِ أَنْكِحُ عَنَاقَ؟ قَالَ فَسَكَتَ عَنِّي فَنَزَلَتْ {الزَّانِي لَا يَنْكِحُ إِلَّا زَانِيَةً أَوْ مُشْرِكَةً وَالزَّانِيَةُ لَا يَنْكِحُهَا إِلَّا زَانٍ أَوْ مُشْرِكٌ وَحُرِّمَ ذَلِكَ عَلَى الْمُؤْمِنِينَ} [النور 3] فَقَرَأَ عَلَيَّ رَسُولُ اللَّهِ ﷺ وَقَالَ «لَا تَنْكِحْهَا»  

هَذَا حَدِيثٌ صَحِيحُ الْإِسْنَادِ وَلَمْ يُخَرِّجَاهُ صحيح

See similar narrations below:

Collected by Qurʾān, Abū Dāwūd
quran:24:3

The fornicator does not marry except a ˹female˺ fornicator or polytheist, and none marries her except a fornicator or a polytheist, and that has been made unlawful to the believers.  

The fornicator shall not marry anyone but a fornicatress or an idolatress, and the fornicatress shall be married by none except a fornicator or an idolator, in other words, what is suitable for each of the two ˹for the purposes of marriage˺ is the above-mentioned; and that, namely, marrying of fornicators, is forbidden to believers, who are better ˹than those˺. This was revealed when the poor among the Emigrants resolved to marry the wealthy whores of the idolaters, so that they ˹the women˺ would provide for them. Thus it is said that the prohibition applies specifically to them; but it is also said to apply in general; but it was abrogated by God’s words: Marry off the spouseless among you ˹Q. 24:32˺.
القرآن:٢٤:٣

الزَّانِي لَا يَنْكِحُ إِلَّا زَانِيَةً أَوْ مُشْرِكَةً وَالزَّانِيَةُ لَا يَنْكِحُهَا إِلَّا زَانٍ أَوْ مُشْرِكٌ ۚ وَحُرِّمَ ذَٰلِكَ عَلَى الْمُؤْمِنِينَ  

{الزاني لا ينكح} يتزوج {إلا زانية أو مشركة والزانية لا ينكحها إلا زان أو مشرك} أي المناسب لكل منهما ما ذكر {وحرم ذلك} أي نكاح الزواني {على المؤمنين} الأخيار، نزل ذلك لما همَّ فقراء المهاجرين أن يتزوجوا بغيا المشركين وهن موسرات لينفقن عليهم فقيل التحريم خاص بهم وقيل عام ونسخ بقوله تعالى (وأنكحوا الأيامى منكم).
abudawud:2051Ibrāhīm b. Muḥammad al-Taymī > Yaḥyá > ʿUbaydullāh b. al-Akhnas > ʿAmr b. Shuʿayb from his father from his grandfather

Marthad ibn AbuMarthad al-Ghanawi used to take prisoners (of war) from Mecca (to Medina). At Mecca there was a prostitute called Inaq who had illicit relations with him. (Marthad said:) I came to the Prophet ﷺ and said to him: May I marry Inaq, Messenger of Allah? The narrator said: He kept silence towards me. Then the verse was revealed:"....and the adulteress none shall marry save and adulterer or an idolater." He called me and recited this (verse) to me, and said: Do not marry her.  

أبو داود:٢٠٥١حَدَّثَنَا إِبْرَاهِيمُ بْنُ مُحَمَّدٍ التَّيْمِيُّ حَدَّثَنَا يَحْيَى عَنْ عُبَيْدِ اللَّهِ بْنِ الأَخْنَسِ عَنْ عَمْرِو بْنِ شُعَيْبٍ عَنْ أَبِيهِ عَنْ جَدِّهِ أَنَّ مَرْثَدَ بْنَ أَبِي مَرْثَدٍ الْغَنَوِيَّ كَانَ يَحْمِلُ الأُسَارَى بِمَكَّةَ وَكَانَ بِمَكَّةَ بَغِيٌّ يُقَالُ لَهَا عَنَاقُ وَكَانَتْ صَدِيقَتَهُ قَالَ

جِئْتُ إِلَى النَّبِيِّ ﷺ فَقُلْتُ يَا رَسُولَ اللَّهِ أَنْكِحُ عَنَاقَ قَالَ فَسَكَتَ عَنِّي فَنَزَلَتْ { وَالزَّانِيَةُ لاَ يَنْكِحُهَا إِلاَّ زَانٍ أَوْ مُشْرِكٌ } فَدَعَانِي فَقَرَأَهَا عَلَىَّ وَقَالَ لاَ تَنْكِحْهَا