Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ibnmajah:189Muḥammad b. Yaḥyá > Ṣafwān b. ʿĪsá > Ibn ʿAjlān from his father > Abū Hurayrah

"The Messenger of Allah said: 'Your Lord wrote for Himself with His Own Hand before He created the creation: "My mercy precedes My wrath."  

ابن ماجة:١٨٩حَدَّثَنَا مُحَمَّدُ بْنُ يَحْيَى حَدَّثَنَا صَفْوَانُ بْنُ عِيسَى عَنِ ابْنِ عَجْلاَنَ عَنْ أَبِيهِ عَنْ أَبِي هُرَيْرَةَ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ كَتَبَ رَبُّكُمْ عَلَى نَفْسِهِ بِيَدِهِ قَبْلَ أَنْ يَخْلُقَ الْخَلْقَ رَحْمَتِي سَبَقَتْ غَضَبِي  


See similar narrations below:

Collected by Tirmidhī, Suyūṭī
tirmidhi:3543Qutaybah > al-Layth > Ibn ʿAjlān from his father > Abū Hurayrah

“Verily, Allah when He created the creation, He wrote with His Hand concerning Himself, that: ‘My mercy prevails over My wrath.’”  

Abū ʿĪsá said that this Ḥadīth is Ḥasan-Ṣaḥīḥ-Gharīb.
الترمذي:٣٥٤٣حَدَّثَنَا قُتَيْبَةُ حَدَّثَنَا اللَّيْثُ عَنِ ابْنِ عَجْلاَنَ عَنْ أَبِيهِ عَنْ أَبِي هُرَيْرَةَ

عَنْ رَسُولِ اللَّهِ ﷺ قَالَ إِنَّ اللَّهَ حِينَ خَلَقَ الْخَلْقَ كَتَبَ بِيَدِهِ عَلَى نَفْسِهِ إِنَّ رَحْمَتِي تَغْلِبُ غَضَبِي  

قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ غَرِيبٌ