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.
bayhaqi:13991Abū Zakariyyā b. Abū Isḥāq from my father

[Machine] In His saying, "And whoever among you cannot [find] the means to marry free, believing women, then [he may marry] from those whom your right hands possess of believing slave girls." (Quran 4:25), it means that whoever does not have the ability to marry free women should marry from the believing slave girls. This is for those who fear that they will commit sin, as this is the better option for them. And it is not permissible for anyone from the free people to marry a slave girl except if they are unable to marry a free woman and fear sin. And if you are patient in refraining from marrying slave girls, it is better for you (Quran 2:54).  

البيهقي:١٣٩٩١أَخْبَرَنَا أَبُو زَكَرِيَّا بْنُ أَبِي إِسْحَاقَ أنبأ أَبُو الْحَسَنِ الطَّرَائِفِيُّ ثنا عُثْمَانُ بْنُ سَعِيدٍ ثنا عَبْدُ اللهِ بْنُ صَالِحٍ عَنْ مُعَاوِيَةَ بْنِ صَالِحٍ عَنْ عَلِيِّ بْنِ أَبِي طَلْحَةَ عَنِ ابْنِ عَبَّاسٍ ؓ

فِي قَوْلِهِ تَعَالَى {وَمَنْ لَمْ يَسْتَطِعْ مِنْكُمْ طَوْلًا أَنْ يَنْكِحَ الْمُحْصَنَاتِ الْمُؤْمِنَاتِ فَمِنْ مَا مَلَكَتْ أَيْمَانُكُمْ مِنْ فَتَيَاتِكُمُ الْمُؤْمِنَاتِ} [النساء 25] يَقُولُ مَنْ لَمْ يَكُنْ لَهُ سَعَةٌ أَنْ يَنْكِحَ الْحَرَائِرَ فَلْيَنْكِحْ مِنْ إِمَاءِ الْمُسْلِمِينَ وَذَلِكَ لِمَنْ خَشِيَ الْعَنَتَ وَهُوَ الْفُجُورُ فَلَيْسَ لِأَحَدٍ مِنَ الْأَحْرَارِ أَنْ يَنْكِحَ أَمَةً إِلَّا أَنْ لَا يَقْدِرَ عَلَى حُرَّةٍ وَهُوَ يَخْشَى الْعَنَتَ {وَأَنْ تَصْبِرُوا} [النساء 25] عَنْ نِكَاحِ الْإِمَاءِ فَهُوَ {خَيْرٌ لَكُمْ} [البقرة 54]