The Messenger of Allah ﷺ said, "Whoever fasts Ramadan out of faith and seeking reward will have his past sins forgiven, and whoever stands in prayer on Laylat al-Qadr out of faith and seeking reward will have his past sins forgiven."
قال رسول الله ﷺ: من صام رمضان إيمانا واحتسابا غفر له ما تقدم من ذنبه، ومن قام ليلة القدر إيمانا واحتسابا غفر له ما تقدم من ذنبه.
Bukhari narrated it in the Book of Fasting (1901), and Muslim in the Book of the Prayer of Travelers (760), both from the hadith of Hisham, who said, Yahya bin Abu Kathir narrated to us, from Abu Salama bin Abdul-Rahman, from Abu Hurairah, and he related it, with the addition of Laylat al-Qadr.