Hadithcore
Mishkat al-Masabih, 2449

‘Ali told of a slave who had made a contract with his master to pay for his freedom(1) coming to him and saying, “I am unable to fulfill my contract,* so give me help.” He suggested teaching him words he had been taught by God’s messenger, which would be so effective that if he had a debt as large as a huge mountain God would pay it for him, telling him to say, “O God, grant me enough of what You makest lawful so that I may dispense with what You makest unlawful, and make me able by Your grace to dispense with all but You.” 1. <i>Mukatab</i>. Although the term comes from the root meaning to write, the contract was not necessarily written. *<i>Kitabati</i>. While the word properly refers to something written, it is used for a contract whether written or not. Tirmidhi and Baihaqi, in <i>[Kitab] ad-Da'awat al-kabir</i>, transmitted it.

وَعَن عليّ: أَنَّهُ جَاءَهُ مُكَاتَبٌ فَقَالَ: إِنِّي عَجَزْتُ عَنْ كتابي فَأَعِنِّي قَالَ: أَلَا أُعَلِّمُكَ كَلِمَاتٍ عَلَّمَنِيهِنَّ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ لَوْ كَانَ عَلَيْكَ مِثْلُ جَبَلٍ كَبِيرٍ دَيْنًا أَدَّاهُ اللَّهُ عَنْكَ. قُلْ: «اللَّهُمَّ اكْفِنِي بِحَلَالِكَ عَنْ حَرَامِكَ وَأَغْنِنِي بِفَضْلِكَ عَمَّنْ سِوَاكَ» . رَوَاهُ التِّرْمِذِيُّ وَالْبَيْهَقِيُّ فِي الدَّعَوَاتِ الْكَبِيرِ وَسَنَذْكُرُ حَدِيثَ جَابِرٍ: «إِذَا سَمِعْتُمْ نُبَاحَ الْكِلَابِ» فِي بَابِ «تَغْطِيَةِ الْأَوَانِي» إِن شَاءَ الله تَعَالَى

References1 variant
In-Book Reference
Book 9, Hadith 218