It is narrated from Sayyiduna Anas bin Malik (may Allah be pleased with him) that he said: "A man said: 'O Messenger of Allah (peace and blessings be upon him), I have not left any need (of sin), small or great, without committing it.' He (peace and blessings be upon him) asked: 'Do you not bear witness that there is no god but Allah and that Muhammad is the Messenger of Allah?' He said: 'Yes!' He (peace and blessings be upon him) said: 'Then surely this (testimony of faith) prevails over all those (sins) (that is, it wipes them out).'"
Imam al-Tabarani (may Allah have mercy on him) said: "No one narrated it from Thabit (may Allah have mercy on him) except Mastur, and Abu Asim (may Allah have mercy on him) is alone in narrating it from him."
Related hadith on this topic