The captives were gathered at Khaybar. Dihya came and said, "Messenger of Allah, give me a slave girl from the captives."The Prophet said, "Go and take a slave girl."So he took Safiya bint Huyayy. Then a man came to the Prophet ﷺ and said, "Prophet of Allah, you gave Dihya," (Yaqub said in his version, "Safiya bint Huyayy, the chief lady of Qurayza and Nadir,") then both narrators agreed, "she is not fitting for anyone but you."The Prophet said, "Call him and bring her with him."When the Prophet ﷺ looked at her, he said to him, "Take another slave girl from the captives instead of her." Then the Prophet ﷺ freed her and married her.
حدثنا داود بن معاذ حدثنا عبد الوارث ح و حدثنا يعقوب بن إبراهيم المعنى قال حدثنا ابن علية عن عبد العزيز بن صهيب
جمع السبي يعني بخيبر فجاء دحية فقال يا رسول الله أعطني جارية من السبي قال اذهب فخذ جارية فأخذ صفية بنت حيي فجاء رجل إلى النبي ﷺ فقال يا نبي الله أعطيت دحية قال يعقوب صفية بنت حيي سيدة قريظة والنضير ثم اتفقا ما تصلح إلا لك قال ادعوه بها فلما نظر إليها النبي ﷺ قال له خذ جارية من السبي غيرها وإن النبي ﷺ أعتقها وتزوجها
Bukhari narrated it in the Book of Jihad and Expeditions, Chapter on one who takes a young boy along on a military expedition for service, hadith no. 2893, from the hadith of Yaqub bin Ibrahim. Muslim narrated it in the Book of Marriage, Chapter on the virtue of freeing one's slave woman and then marrying her, hadith no. 1365, after hadith no. 1427, from the hadith of Ismail bin Ulaya, through the same chain.