Qur'an states:
وَمَا أَرْسَلْنَا مِن رَّسُولٍ إِلَّا لِيُطَاعَ بِإِذْنِ اللَّهِ ۚ وَلَوْ أَنَّهُمْ إِذ ظَّلَمُوا أَنفُسَهُمْ جَاءُوكَ فَاسْتَغْفَرُوا اللَّهَ وَاسْتَغْفَرَ لَهُمُ الرَّسُولُ لَوَجَدُوا اللَّهَ تَوَّابًا رَّحِيمًا
Translation: We sent not the Messenger, but to be obeyed, in accordance with the will of Allah. If they had only, when they were unjust to themselves, come to the Messenger and asked Allah's forgiveness, and the Messenger had (also) asked forgiveness for them, they would have found Allah indeed Oft-returning, Most Merciful.(Al-Qur'an, Surah an-Nisa, 4:64)