It is narrated from Ibn Umar (may Allah be pleased with them) that he reported from Aisha (may Allah be pleased with her) that she bought a slave girl with the intention of freeing her. Her owners said: "We sell her to you on the condition that her wala’ (right of inheritance/loyalty) will be for us." She mentioned this to the Messenger of Allah (ﷺ), and he said: "Do not let this prevent you (from freeing her), for wala’ belongs to the one who sets free."
Hadith Referenceمسند الإمام الشافعي / كتاب العتق والولاء والمدبر والمكاتب وحسن الملكة / 1077
Hadith Takhrijاخرجه البخاري، البيوع، باب اذا اشترط في البيع شروطا لا تحل (2169) ومسلم، العتق ، باب بيان أن الولاء لمن اعتق (1504)۔