Short answer
No. Sunni scholars agree that the prophets, and the Prophet Muhammad ﷺ above all, were protected (ma'sum) from major sins and from anything that would damage their message. Where the Quran speaks of his "sin" being forgiven, scholars explain it as leaving what was better, not sin as we commit it.
In Hanafi-Maturidi creed, the prophets are protected from disbelief, from all major sins and from deliberate minor sins. What the texts call their slips (zallat) were unintended, or the choice of a good thing over a better one, and they were corrected at once.
The four schools agree on this.
Explanation
Allah commands us to follow the Prophet ﷺ and calls him an excellent example (33:21). He also says the Prophet does not speak from his own desire; it is revelation (53:3-4). If he could sin deliberately, following him could mean following a sin, so scholars say his protection ('isma) is required by the message itself.
Why then does the Quran say "that Allah may forgive for you what preceded of your sin and what will follow" (48:2)? Scholars give several answers. The word covers anything below his own high station, such as choosing a good option when another was better. The verse is a declaration of honour, telling him he is free of all blame. Some say it refers to his ummah through him. A saying often quoted by scholars puts it well: the good deeds of the righteous are the shortcomings of those brought near to Allah.
His constant istighfar (seeking forgiveness) fits this. He said he asked Allah's forgiveness more than seventy times a day. It was worship, humility and teaching, not a sign of hidden sins. When he prayed at night until his feet swelled, Aisha asked why, since he had been forgiven. He said: "Should I not love to be a grateful servant?"
Examples people raise, such as the blind man in Surah Abasa (80:1-2), are cases of choosing between two good actions: he turned to the leaders of Quraysh hoping they would accept Islam. Allah taught him the better choice, and he honoured that man for the rest of his life. Read his life on Prophet Muhammad ﷺ and Seerah.
The evidence
Quran, Surah Al-Ahzaab 33:21
لَّقَدْ كَانَ لَكُمْ فِى رَسُولِ ٱللَّهِ أُسْوَةٌ حَسَنَةٌۭ لِّمَن كَانَ يَرْجُوا۟ ٱللَّهَ وَٱلْيَوْمَ ٱلْءَاخِرَ وَذَكَرَ ٱللَّهَ كَثِيرًۭا ﴿٢١﴾
There has certainly been for you in the Messenger of Allah an excellent pattern for anyone whose hope is in Allah and the Last Day and [who] remembers Allah often.
He is the model to follow, so he could not model sin.
Quran, Surah An-Najm 53:3-4
وَمَا يَنطِقُ عَنِ ٱلْهَوَىٰٓ ﴿٣﴾ إِنْ هُوَ إِلَّا وَحْىٌۭ يُوحَىٰ ﴿٤﴾
Nor does he speak from [his own] inclination. It is not but a revelation revealed,
His teaching comes from revelation.
Quran, Surah Al-Fath 48:2
لِّيَغْفِرَ لَكَ ٱللَّهُ مَا تَقَدَّمَ مِن ذَنۢبِكَ وَمَا تَأَخَّرَ وَيُتِمَّ نِعْمَتَهُۥ عَلَيْكَ وَيَهْدِيَكَ صِرَٰطًۭا مُّسْتَقِيمًۭا ﴿٢﴾
That Allah may forgive for you what preceded of your sin and what will follow and complete His favor upon you and guide you to a straight path
The verse scholars explain as honour, not proof of real sin.
Sahih al-Bukhari 6307
Sahih... إِنِّي لأَسْتَغْفِرُ اللَّهَ وَأَتُوبُ إِلَيْهِ فِي الْيَوْمِ أَكْثَرَ مِنْ سَبْعِينَ مَرَّةً ...
"By Allah, I seek Allah's forgiveness and repent to Him more than seventy times a day."
His istighfar was worship and an example for his ummah.
Sahih al-Bukhari 4837
Sahih... أَفَلاَ أُحِبُّ أَنْ أَكُونَ عَبْدًا شَكُورًا ...
"Should I not love to be a grateful servant?"
His worship came from gratitude, not from fear of past sins.
Where the ruling is recorded
- al-Fiqh al-Akbar (Imam Abu Hanifa), Section on the prophets. States that the prophets are free of minor and major sins, of disbelief and of vile acts, though slips may occur.
- al-Shifa (Qadi Iyad), Part on the protection ('isma) of the prophets. The fullest classical treatment of the protection of the Prophet and how to read the verses about his sin.
This answer is pending review by the scholars on our team. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.