Sayyiduna Amr bin al-As (may Allah be pleased with him), narrating the story of his acceptance of Islam, says: I stepped forward and said: O Messenger of Allah (peace and blessings be upon him)! I will pledge allegiance to you (peace and blessings be upon him) on the condition that my past sins are forgiven, and I did not mention the later ones. He (peace and blessings be upon him) said to me: "O Amr! Pledge allegiance, for Islam wipes out all the sins before it, and through Hijrah too the sins before it are forgiven." So I pledged allegiance to him.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18290