Did Prophet Muhammad Sin?
Question

My question is about the Prophet. Some Muslims believe that he was sinless while others say he was not. I personally don’t think he was sinless cause he was just a human. Can u tell me which is true using Quran or Hadith, please?
Praise be to Allah.Prophets are infallible
First: The Ummah has agreed that the prophets are infallible in conveying the message and religion, and that they do not conceal anything that Allah has revealed to them, so they are infallible in conveying from Allah the Almighty.
Shaykh Al-Islam (may Allah have mercy on him) said: “The verses indicating the prophethood of the prophets denote that they are infallible in what they tell from Allah the Almighty, so their words are nothing but the truth, and this is the meaning of prophethood which includes that Allah informs the prophet of the unseen and that he informs people of the unseen. The Messenger is commanded to call people and convey to them the messages of his Lord.” (End quote from Majmu` Al-Fatawa, 18/7).
Prophets may commit minor Sin
Second: Prophets were protected from major sins but not from minor sins. Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
“The view that the Prophets were protected from major sins but not from minor sins is the view of the majority of the scholars of Islam and all the sects… It is also the view of the majority of the scholars of Tafsir and Hadith, and of the jurists. Nothing was reported from any of the Salaf, Imams, Companions, Successors of the Companions (Tabi`un) or the successive generation that does not agree with this view.” (End quote from Majmu` Al-Fatawa, 4/319).
This question was posed to the Standing Committee on this topic:
Question:
Some people, including the heretics, say that the Prophets and Messengers could make mistakes, i.e., they could make mistakes like all other people. They say that the first mistake ever made was when the son of Adam, Qabil, killed Habil… and when the two angels came to Dawood, he listened to the first and did not listen to what the second had to say… and the story of Yoonus when the big fish swallowed him; and the story of the Messenger with Zayd ibn Harithah, they say that he concealed something which he should have declared openly; and with his Companions, he told them, “You know better about your worldly affairs,” and they say that this is because he made a mistake in this regard; and what happened with the blind man, which is referred to in the verse (interpretation of the meaning), {(The Prophet) frowned and turned away, because there came to him the blind man…} [`Abasa 80:1-2]. Could the Prophets and Messengers really make mistakes? How can we respond to these sinners [who say these things]?
Answer:
“Yes, the Prophets and Messengers made mistakes, but Allah did not approve of their mistakes; rather, He pointed out their mistakes as a Mercy to them and their nations, and He forgave their mistakes and accepted their repentance as a Grace and Mercy, for Allah is Oft-Forgiving, Most Merciful. This will be clear to anyone who checks out the verses of the Quran in which the matters raised in the question are discussed… With regard to the sons of Adam, even though they were not Prophets… Allah explained how evil was the deed which he did to his brother…” (End quote from Fatawa Al-Lajnah Ad-Da’imah, 6290, 3/194)
Is the ruling different after the message than before it?
Before they were given their Mission (Risalah), the scholars have said that it is possible that they may have committed some minor sins, but they were protected from committing major sins such as Zina, drinking wine, etc.
But after they received their Mission, the correct view is that they may have committed some minor mistakes but this was not approved of and they were rebuked.
Shaykh Al-Islam [Ibn Taymiyah] (may Allah have mercy on him) said:
“Most of the reports from the majority of scholars state that they were not infallible with regard to minor mistakes, but they were not allowed to persist in them; they do not say that this could never happen at all. The first suggestion that they were completely infallible came from the Rafidis, who say that they are so infallible that they could never make any mistake even by way of forgetfulness and misunderstanding.” (End quote from Majmu` Al-Fatawa, 4/320)
Understanding unintentional mistakes
Mistakes which are committed unintentionally are of two types:

With regard to worldly matters: this happened to the Messenger of Allah (peace and blessings of Allah be upon him). With regard to agriculture, medicine, carpentry, etc., he was like all other people. Allah did not tell us that he was sent to us as a businessman or a farmer or a carpenter or a doctor. His mistakes in these fields are quite natural and do not impact his Message at all.

It was reported that Rafi` ibn Khudayj said: The Prophet (peace and blessings of Allah be upon him) came to Madinah, and they were pollinating the date-palms. He said, “What are you doing?” They said, “We always used to pollinate them.” He said, “Perhaps if you do not do that, it will be better.” So they did not do it, and the harvest was lacking. They mentioned that to him, and he said, “I am only a human being like you. If I tell you to do something with regard to religion, then follow it, but if I tell you to do something based on my own opinion, I am only a human being.” (Narrated by Muslim, 2361)
We note that the Messenger (peace and blessings of Allah be upon him) made a mistake in this worldly matter, because he was like all other human beings, but with regard to matters of religion he did not make mistakes.

With regard to unintentional mistakes concerning matters of religion:

The most correct view among the scholars is that the way this happened with regard to the Prophet (peace and blessings of Allah be upon him) is that he might do something which is OK but it was not the more appropriate choice.
He was sometimes faced with issues concerning which there was no Shar`i text on which he could base his decision, so he sought to make Ijtihad based on his own opinion, just as any Muslim scholar may make Ijtihad, and if he makes the right decision, he will be given two rewards, and if he makes the wrong decision, he will still be given one reward. This is what the Prophet (peace and blessings of Allah be upon him) said: “If the judge makes Ijtihad and gets it right, he will have two rewards, and if he makes Ijtihad and gets it wrong, he will have one reward.” (Narrated by Al-Bukhari, 6919 and Muslim, 1716, from the Hadith of Abu Hurayrah)
Cases of Ijtihad and consultation
This also happened to him concerning the prisoners of Badr.
Anas said: The Messenger of Allah (peace and blessings of Allah be upon him) consulted the people concerning the prisoners who had been captured on the day of Badr. He said, “Allah has given you power over them.”
`Umar ibn Al-Khattab (may Allah be pleased with him) stood up and said, “O Messenger of Allah, strike their necks [execute them]!” The Prophet (peace and blessings of Allah be upon him) turned away from him. Then the Messenger of Allah (peace and blessings of Allah be upon him) came back and said, “O people, Allah has given you power over them and they were your brothers.” `Umar stood up and said, “O Messenger of Allah, strike their necks [execute them]!” The Prophet (peace and blessings of Allah be upon him) turned away from him. Then the Prophet (peace and blessings of Allah be upon him) came back and said something similar to the people.
Abu Bakr (may Allah be pleased with him) stood up and said, “O Messenger of Allah, why don’t you forgive them and accept payment of ransom from them?” The worried expression left the face of the Messenger of Allah (peace and blessings of Allah be upon him), and he forgave them and accepted their payment of ransom. Then Allah revealed the words (interpretation of the meaning):
{If not for a decree from Allah that preceded,1 you would have been touched for what you took by a great punishment} [Al-Anfal 8:68]” (Narrated by Ahmad, 13143)
We may note that in this case, the Messenger of Allah (peace and blessings of Allah be upon him) did not have any clear text so he made Ijtihad and consulted his companions, and he made a mistake in deciding what was the best thing to do.
Allah knows best.