Sahih Bukhari | Volume 9 | Hadith Number 643

Narrated by Abu Huraira
I heard Allah's Apostle saying, "Before Allah created the creations, He wrote a Book (wherein He has written): My Mercy has preceded my Anger." and that (Book) is written with Him over the Throne."