The wife of a high Egyptian official, named Potiphar in the Bible (Genesis 39:1), uses the same word in: I did seek to seduce him, but he firmly saved himself guiltless (12:32). The Qur'an calls believers to hold fast to the rope of God—the Qur'an and Islam—using the same word in a different form: Hold fast all together to, and protect (against being divided), the rope of God (3:103). Again, we see the same word in the verse: God will defend (protect) you from people (5:67).
The infallibility of Prophets is an established fact based on reason and tradition. This quality is required for several reasons. First, Prophets came to convey the Message of God. If we liken this Message to pure water or light, as the Qur'an does (13:17, 24:35), the Archangel Gabriel (who brought it) and the Prophet (who conveyed it) also must be absolutely pure. If this were not the case, their impurity would pollute the Message. Every falling off is an impurity, a dark spot, in the heart. The hearts or souls of Gabriel and the Prophet are like polished mirrors that reflect the Divine Revelation to people, a cup from which people quench their thirst for the pure, Divine water.
Any black spot on the mirror would absorb a ray of that light; a single drop of mud would make the water unclear. As a result, the Prophets would not be able to deliver the complete Message. But they delivered the Message perfectly, as stated in the Qur'an: O Messenger! Convey what has been sent to you from your Lord. If you did not, you would not have fulfilled His mission. And God will defend you from people. Certainly, God guides not the unbelieving people (5:67) and: Today I have perfected your religion for you, and I have completed My favor upon you, and I have chosen and approved for you Islam as religion (5:3).
Second, the Prophets teach their people all the commands and principles of belief and conduct. So that the people learn their religion in its pristine purity and truth, and as perfectly as possible to secure their happiness and prosperity in both worlds, the Prophets must represent and then present the Revelation without fault or defect. This is their function as guides and good examples to be followed: You have in the Messenger of God a beautiful pattern, an excellent example, for anyone who aspires after God and the Last Day, and who engages much in the remembrance of God (33:21) and: There is for you an excellent example in Abraham and those with him … there was in them an excellent example for you—for those who aspire after God and the Last Day (60:4, 6).
A Prophet can do or say only that which has been sanctioned by God. If he could, he would have to repent even beyond his current lifetime. For example, Abraham will tell those who approach him for intercession on the Day of Judgment to go to Moses, saying he cannot intercede for them because he spoke allusively three times in his life. Although this is not a sin, his repentance will continue in the Hereafter.
Third, the Qur'an commands believers to obey the Prophet's orders and prohibitions, without exception, and emphasizes that it is not fitting for a believer, man or woman, when a matter has been decided by God and His Messenger, to have any option about their decision (33:36). It also warns believers that what falls to them when God and His Messenger have given a judgment is only to say: "We have heard and obeyed" (24:51). Absolute obedience to a Prophet means that all of his commands and prohibitions are correct and beyond reproach.
Prophethood is so great a favor that all Prophets bore extreme hardship while fulfilling the duty of thanksgiving, and always worried about not worshipping God sufficiently. Prophet Muhammad often implored God as follows: "Glory be to You. We have not been able to know You as Your knowledge requires, O Known One. Glory be to You. We have not been able to worship You as Your worship requires, O Worshipped One."
The Qur'anic verses that are sometimes understood—mistakenly—to reprimand certain Prophets for some faults or to show that they seek God's forgiveness for some sin, should be considered in this light. Besides, God's forgiveness does not always mean that a sin has been committed. The Qur'anic words 'afw (pardon) and maghfira (forgiveness) also signify a special favor and kindness, as well as Divine dispensation, in respect to lightening or overlooking a religious duty, as in the following verses: If any is forced (to eat of them) by hunger, with no inclination towards transgression, God is indeed Oft-Forgiving, Most Merciful (5:3) and: If... you find no water, then take for yourselves clean sand or earth, and rub therewith your faces and hands. For God is All-Pardoning and Oft-Forgiving (4:43).
Fifth, sins and pardoning have different types and degrees. These are: disobeying religious commandments, and forgiveness thereof; disobeying God's laws of creation and life, and forgiveness thereof; and disobeying the rules of good manners or courtesy (adab), and the forgiveness thereof. A fourth type, which is not a sin, involves not doing something as perfectly as possible, which is required by the love of and nearness to God. Some Prophets may have done this, but such acts cannot be considered sins according to our common definition of that word.
Tradition also proves the Prophets' infallibility. God says of Moses: I cast love over you from Me (and made you comely and loveable) in order that you might be brought up under My eye (20:39). Thus, as Moses was brought up by God Himself and prepared for the mission of Messengership, how could he possibly commit a sin?
The same is true of all other Prophets. For example, God's Messenger says of Jesus: "Satan could not touch Jesus and his mother at his birth." Jesus was protected from birth until his elevation to the Presence of God:
(Mary) pointed to the infant (Jesus). They asked: "How can we talk to an infant in the cradle?" Jesus said: "I am a servant of God. He has given me the Scripture and made me a Prophet. He has made me blessed wheresoever I be, and enjoined on me prayer and charity as long as I live. He has made me kind to my mother, and not overbearing or a wretched rebel. So peace is on me the day I was born, the day that I die, and the day that I will be raised up to life again." (19:29-33)
Jesus, like all Prophets, was protected from sin from his birth. God's Messenger, while still a child and not yet a Prophet, intended to attend two wedding ceremonies, but on each occasion was overpowered by sleep.  Likewise, during his youth he helped his uncles repair the Ka'ba by carrying stones. Since the stones hurt his shoulders, his uncle 'Abbas advised him to wrap part of his lower garment around his shoulders for padding. But as soon as he did so, thereby leaving parts of his thighs exposed, he fell on his back and stared fixedly. An angel appeared and warned him that: "This is not befitting for you,"  for in the future he would tell people to be well-mannered and observe Divinely ordained standards of conduct, including covering the thighs. In such ways was the future Prophet protected from the pagan rituals and practices of his people.
God's Messenger says that "all children of Adam make mistakes and err, and the best of those who make faults and err are the repentant."  This implies that we are fallible by nature, not that we are condemned to make such mistakes. Whether by God's Will and special protection or, as will be explained below, by His showing the way to become free of error or sin, even the greatest saints who continue the Prophetic mission may be infallible to some degree.
God promises to protect believers who obey Him in utmost respect and deserve His protection, and to endow them with sound judgment so that they can distinguish between truth and falsehood, right and wrong: O you who believe! If you obey God in utmost respect, He will establish in you a Criterion (to judge between right and wrong), purify you of all your evils, and forgive you. God is of grace unbounded (8:29).
God made a covenant with the believers that if they obey Him and strive to exalt His Word, by proclaiming His religion, He will help them and establish them firmly in the religion, protecting them against all kinds of deviation (47:7). This protection from enemies and committing sins depends upon their support of Islam and the struggle to spread it so that only God is worshipped, and that no partners are associated with Him in belief or worship, or in the creation and rule of the universe. If believers keep their promise, God will keep His (2:40); if they break it, God will cause them to fail (17:8).
God protects His servants against sin in different ways. For example, he may place obstacles in their way, establish a "warner" in their hearts, or even cause them to suffer some injury so that they physically cannot sin. Or, He may put a verse in someone's mouth, as happened with a young man during 'Umar's caliphate.
The young man was so strict and attentive in his worship that he prayed every prayer in the mosque. A woman who lived on his way to the mosque had become enamored with him and so sought to seduce him. Although he resisted her gestures, the moment came when he took a few steps in her direction. Just at this moment, he felt he was reciting: Those who fear God, when a thought of evil from Satan assaults them, bring God to remembrance, and lo! they see (aright) (7:201). Overwhelmed with shame before God, and with love of God for preventing him from committing this sin, he fell down dead. When 'Umar was informed of this a few days later, he went to his grave and shouted: "O young man. For those who fear the time when they will stand before the Lord, there will be two gardens!" (55:46). A voice from the grave, whether that of the young man or an angel on his behalf, replied: "O Commander of the Believers, God has granted me the double of what you say."
This is how God protects His sincere servants. He says in a hadith qudsi: My servants cannot draw near to me through something else more lovable to Me than performing the obligations I have enjoined upon them. Apart from those obligations, they continue to draw near to Me through supererogatory acts of worship, until I love them. When I love them, I will be their ears with which they hear, their eyes with which they see, their hands with which they grasp, and their feet on which they walk. If they ask Me for something, I will give it to them immediately. If they seek refuge in Me from something, I will protect them from it.
God guides His true servants to good and protects them from evil. The servants will and do what is good, and refrain from wickedness. They ask God for what is good, and whatever they ask is provided. They seek refuge in God from what is bad, and God protects them according to their request.
All Prophets were infallible, sinless, and lived completely virtuous lives. Although God sent numerous Prophets, the Qur'an specifically mentions only 28 of them. I think it would be proper here to count them in the words of Ibrahim Haqqi, an eighteenth-century Turkish saint and religious scholar, who also was an expert in anatomy and astronomy:
Some have regarded it a religious injunction to learn the names of the Prophets.
God informed us of 28 of them in the Qur'an:
Adam, Enoch, Noah, Hud, and Salih;
Abraham, Isaac, and Ishmael, who was a sacrifice for God;
Jacob, Joseph, Shu'ayb, Lot, and John the Bapitst;
Zachariah and Aaron, the brother of Moses, who spoke to God;
David, Solomon, Elijah, and Job;
Elisha, a relative of Jesus, who was a spirit from God;
Dhul-Kifl and Jonah, who was certainly a Prophet.
The Seal of Prophets is the Beloved of God—Muhammad, Messenger of God. Scholars disagree on the Prophethood of Ezra, Luqman, and Dhul-Qarnayn. Some regard them as Prophets, while others consider them saints of God.
 Bukhari, "Hajj," 42; Ibn Kathir, "Al-Bidaya," 2:350.
 Tirmidhi, "Qiyama," 49; Ibn Maja, "Zuhd," 30.