It is narrated from Sayyidah Aisha (may Allah be pleased with her): I intended to buy Barirah (may Allah be pleased with her) and set her free. Her owners placed a condition on me that I should set her free, but the right of wala (allegiance) would remain with them. So I asked the Messenger of Allah (peace and blessings be upon him) about this issue. He said: "Buy her and set her free; the right of wala belongs only to the one who sets her free." Then the Messenger of Allah (peace and blessings be upon him) addressed the people and said: "What is the matter with people who stipulate such and such conditions which are not in the law of Allah? Whoever stipulates a condition contrary to the law of Allah will get nothing, even if he makes a hundred such conditions."
Hadith Referenceالسنن المأثورة / باب في أكل لحوم الخيل والبغال والحمير / 583
Hadith Takhrijصحیح بخاری، الصلاة، باب ذکر البیع والشراء علی المنبر فی المسجد، رقم: 456۔