The Messenger of Allah ﷺ said, "When Allah finished creating, He wrote in His book, which is with Him above the Throne, 'My mercy has overcome My wrath.'"
قال رسول الله ﷺ: لما قضى الله الخلق كتب في كتابه فهو عنده فوق العرش: إن رحمتي غلبت غضبي.
Bukhari narrated it in the Book of the Beginning of Creation (3194), and Muslim in the Book of Repentance (2751), both from Qutayba bin Saeed, who said, Mughira bin Abdul-Rahman Qurashi told us, from Abu Zinad, from Araj, from Abu Hurairah, and he related it. The wording given is Bukhari's, and Muslim's wording is similar. Muslim then also narrated it through the hadith of Sufyan bin Uyayna, from Abu Zinad, with the wording, "My mercy has preceded my wrath."