كتاب العتق
20  
The Book of Emancipating Slaves
(3)
Chapter: Al-Wala' (Right of inheritance) belongs to the one who manumits the slave
(3)
باب إِنَّمَا الْوَلاَءُ لِمَنْ أَعْتَقَ
Sahih Muslim 1504 a

Ibn Umar reported that 'A'isha decided to buy a slave-girl and then set her free, but her masters said:

We are prepared to sell her to you on the condition that her right of inheritance would vest with you. She (Hadrat A'isha) made a mention of that to Allah's Messenger (ﷺ) whereupon he said: This should not stand in your way. The right of inheritance vests in one who emancipates.
وَحَدَّثَنَا يَحْيَى بْنُ يَحْيَى، قَالَ قَرَأْتُ عَلَى مَالِكٍ عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، عَنْ عَائِشَةَ، أَنَّهَا أَرَادَتْ أَنْ تَشْتَرِيَ، جَارِيَةً تُعْتِقُهَا فَقَالَ أَهْلُهَا نَبِيعُكِهَا عَلَى أَنَّ وَلاَءَهَا لَنَا ‏.‏ فَذَكَرَتْ ذَلِكَ لِرَسُولِ اللَّهِ صلى الله عليه وسلم فَقَالَ ‏ "‏ لاَ يَمْنَعُكِ ذَلِكَ فَإِنَّمَا الْوَلاَءُ لِمَنْ أَعْتَقَ ‏"‏‏.‏
Reference : Sahih Muslim 1504a
In-book reference : Book 20, Hadith 7
USC-MSA web (English) reference : Book 9, Hadith 3584
  (deprecated numbering scheme)