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 made a contract of emancipation with my masters for nine uqiyahs of silver, paying one uqiyah each year, so please help me." Aisha (may Allah be pleased with her) said to her: "If your masters wish, I am ready to give them this money, but your wala (allegiance) will be for me." Barirah (may Allah be pleased with her) went to her masters (and then returned) while the Messenger of Allah (ﷺ) was present. She came and said: "I presented this matter to them, but they refused unless the wala remains with them." The Messenger of Allah (ﷺ) heard this and asked her about it, so Aisha (may Allah be pleased with her) told him the whole story. The Messenger of Allah (ﷺ) said: "Buy her and stipulate the condition of wala, for wala is 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 Allah, and said: "What is the matter with some people who stipulate conditions which are not in Allah's Book? Any condition that is not in Allah's Book is invalid, even if there are a hundred such conditions. Allah's decision is truer and His condition is firmer, and indeed, wala is for the one who sets free."
Hadith Referenceمسند الإمام الشافعي / كتاب العتق والولاء والمدبر والمكاتب وحسن الملكة / 1079