Sunan Abi Dawud, Hadith 3929

'Urwah quoting from 'Aishah said that Barirah came to her seeking her help to purchase her freedom, and she did not pay anything for her freedom. 'Aishah said to her: Return to your people ; if you like that I make payment for the purchase of your freedom on your behalf and I shall have the right to inherit from you, I shall do so. Barirah mentioned it to her people, but they refused and said: If she wants to purchase your freedom for reward from Allah, she may do so, but the right to inherit from her shall be ours. She mentioned it to the Messenger of Allah. The Messenger of Allah said: Purchase her (freedom) and set her free, for the right of inheritance belongs to only to the one who set a person free. The Messenger of Allah then stood up and said: If anyone makes a condition which is not in Allah's Book, he has no right to it, even if he stipulates it hundred times. Allah's condition is more valid and binding.

حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مَسْلَمَةَ، وَقُتَيْبَةُ بْنُ سَعِيدٍ، قَالاَ حَدَّثَنَا اللَّيْثُ، عَنِ ابْنِ شِهَابٍ، عَنْ عُرْوَةَ، أَنَّ عَائِشَةَ، رضى الله عنها أَخْبَرَتْهُ أَنَّ بَرِيرَةَ جَاءَتْ عَائِشَةَ تَسْتَعِينُهَا فِي كِتَابَتِهَا وَلَمْ تَكُنْ قَضَتْ مِنْ كِتَابَتِهَا شَيْئًا فَقَالَتْ لَهَا عَائِشَةُ ارْجِعِي إِلَى أَهْلِكِ فَإِنْ أَحَبُّوا أَنْ أَقْضِيَ عَنْكِ كِتَابَتَكِ وَيَكُونَ وَلاَؤُكِ لِي فَعَلْتُ ‏.‏ فَذَكَرَتْ ذَلِكَ بَرِيرَةُ لأَهْلِهَا فَأَبَوْا وَقَالُوا إِنْ شَاءَتْ أَنْ تَحْتَسِبَ عَلَيْكِ فَلْتَفْعَلْ وَيَكُونَ لَنَا وَلاَؤُكِ ‏.‏ فَذَكَرَتْ ذَلِكَ لِرَسُولِ اللَّهِ صلى الله عليه وسلم فَقَالَ لَهَا رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ ابْتَاعِي فَأَعْتِقِي فَإِنَّمَا الْوَلاَءُ لِمَنْ أَعْتَقَ ‏"‏ ‏.‏ ثُمَّ قَامَ رَسُولُ اللَّهِ صلى الله عليه وسلم فَقَالَ ‏"‏ مَا بَالُ أُنَاسٍ يَشْتَرِطُونَ شُرُوطًا لَيْسَتْ فِي كِتَابِ اللَّهِ مَنِ اشْتَرَطَ شَرْطًا لَيْسَ فِي كِتَابِ اللَّهِ فَلَيْسَ لَهُ وَإِنْ شَرَطَهُ مِائَةَ مَرَّةٍ شَرْطُ اللَّهِ أَحَقُّ وَأَوْثَقُ ‏"‏ ‏.‏

sunnah.com

also referenced under: Hadith 3918 (Hasan)