Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:4:64

And We did not send any messenger except to be obeyed by permission of Allah. And if, when they wronged themselves, they had come to you, ˹O Muhammad˺, and asked forgiveness of Allah and the Messenger had asked forgiveness for them, they would have found Allah Accepting of repentance and Merciful.  

We never sent any Messenger, but that he should be obeyed, in what he commands and judges, by the leave, by the command, of God, and not that he should be disobeyed or opposed. If, when they had wronged themselves, by seeking the judgement of the false idol, they had come to you, repentant, and asked forgiveness from God, and the Messenger had asked forgiveness for them (there is a shift from the second ˹to the third˺ person in this address, in deference to his ˹the Prophet’s (s)˺ status); they would have found God Relenting, to them, Merciful, to them.
القرآن:٤:٦٤

وَمَا أَرْسَلْنَا مِنْ رَسُولٍ إِلَّا لِيُطَاعَ بِإِذْنِ اللَّهِ ۚ وَلَوْ أَنَّهُمْ إِذْ ظَلَمُوا أَنْفُسَهُمْ جَاءُوكَ فَاسْتَغْفَرُوا اللَّهَ وَاسْتَغْفَرَ لَهُمُ الرَّسُولُ لَوَجَدُوا اللَّهَ تَوَّابًا رَحِيمًا  

{وما أرسلنا من رسول إلا ليُطاع} فيما يأمر به ويحكم {بإذن الله} بأمره لا ليعصى ويخالف {ولو أنهم إذ ظلموا أنفسهم} بتحاكمهم إلى الطاغوت {جاءُوك} تائبين {فاستغفروا الله واستغفر لهم الرسول} فيه التفات عن الخطاب تفخيما لشأنه {لوجدوا الله توَابا} عليهم {رحيما} بهم.