Imam al-Shafi'i (may Allah have mercy on him) said: When her people agreed to the sale and the mukatabah agreed to be sold, the contract of manumission is ended. Imam al-Shafi'i (may Allah have mercy on him) said: Some people asked me: What is the meaning of the Prophet (peace and blessings be upon him) voiding the condition of Barirah's people? He said: Allah knows best, but it is clear from the hadith itself that the Messenger of Allah (peace and blessings be upon him) had informed them that Allah has decreed that "the wala' belongs to the one who frees." And He said: "Call them by (the names of) their fathers; that is more just in the sight of Allah. But if you do not know their fathers, then they are your brothers in religion and your freed ones (mawali)." [Surah al-Ahzab: 5] They are attributed to the one who freed them just as they are attributed to their fathers. Just as it is not permissible to change the attribution from the father, likewise it is not permissible to change the attribution from the one who freed them, who became the guardian of this favour upon them. Allah Almighty said: "And when you (peace and blessings be upon him) said to the one on whom Allah had bestowed favour and you too had bestowed favour: Keep your wife." [Surah al-Ahzab: 37]
And the Messenger of Allah (peace and blessings be upon him) said: "The wala' belongs to the one who frees," and he (peace and blessings be upon him) forbade selling the wala' and giving it as a gift. In one narration it is: "The wala' is a bond like the bond of lineage, and lineage is not sold or given as a gift." When this reached them, whoever stipulated a condition contrary to what Allah and His Messenger decided is a sinner, so his condition will be declared void, so that he and others like him take a lesson from it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المكاتب / 21738