Narrated from Aisha (may Allah be pleased with her), she said: Barirah (may Allah be pleased with her) came to me and said: "I have entered into a contract of manumission with my masters for nine uqiyah of silver, to be paid in installments of one uqiyah per year, so please help me." Aisha (may Allah be pleased with her) said to her: "If your masters wish that I pay them this amount, I am ready to do so, but your freedom will be attributed to me." Barirah (may Allah be pleased with her) went to her masters and told them this, but they refused. She returned from her masters while the Messenger of Allah (ﷺ) was present, and she said: "I presented this to them but they refused to accept it unless the wala’ (right of inheritance/loyalty) would be for them." When the Messenger of Allah (ﷺ) heard this, he asked her about the whole matter, and Aisha (may Allah be pleased with her) informed him. Then the Messenger of Allah (ﷺ) said to her: "Buy her and stipulate the condition of wala’ for them, for wala’ is only for the one who sets free." So Aisha (may Allah be pleased with her) did so. Then the Messenger of Allah (ﷺ) stood among the people, praised and glorified Allah, and then said: "What is the matter with some people who stipulate conditions that are not in the Book of Allah? Any condition that is not in the Book of Allah is invalid, even if there are a hundred such conditions. The decision of Allah is truer and His condition is stronger, and indeed, wala’ is for the one who sets free."
Hadith Referenceمسند الإمام الشافعي / كتاب العتق والولاء والمدبر والمكاتب وحسن الملكة / 1074
Hadith Takhrijاخرجه البخاري، البيوع، باب اذا اشترط في البيع شروطا لا تحل (2168)۔ مسلم، العتق ، باب بيان أن الولاء عن أعتق (1504)۔