One event worthy of further elaboration is the Treaty of Hudaybiya. In 6 ah, the Messenger told his Companions that he had dreamed they would shortly enter the Holy Mosque in Makka in security, with their heads shaved or their hair cut short. His Companions, especially the Emigrants, were delighted. During that year, the Prophet set out for Makka with 1,500 unarmed men in pilgrim dress (ihram).
Informed of this event, the Quraysh armed themselves and the neighboring tribes to keep the Muslims out of Makka. They sent some 200 soldiers, led by Khalid ibn Walid and Ikrima ibn Abu Jahl, as far as Qura' al-Ghamim. Seeing the Muslims approaching, they returned to Makka to spread the news. When the Muslims reached Hudaybiya, about 12 miles from Makka, the Messenger told them to halt. Learning that there was a shortage of water, he threw an arrow down Hudaybiya's only well. Water began to gush and fill the well. Everyone drank some, performed wudu', and filled their water-skins. 
As the Makkans refused to let the Muslims enter Makka, the Messenger sent Budayl ibn Warqa, a man from the Khuda'a tribe (the Muslims' ally), to announce that the Muslims had come for pilgrimage and thus were unarmed. The Quraysh, in reply, sent 'Urwa ibn Mas'ud al-Thaqafi. While talking to the Messenger 'Urwa tried to grasp his beard, a sign of jesting. Mughira ibn Shu'ba struck his hand, saying he would cut it off if 'Urwa tried such a thing again, for his hand was impure.
Mughira was 'Urwa's cousin, and had accepted Islam about 2 months earlier. In fact, only a few months ago 'Urwa had paid the blood money for a crime Mughira had committed. How Islam had changed Mughira! The Companions' commitment to their cause and devotion to the Messenger shocked 'Urwa, who returned to the Quraysh and said: "I have visited Chosroes, Caesar, and the Negus. None of their subjects are so devoted to their rulers as his Companions are to Muhammad. I advise you not to struggle with him." 
The Quraysh did not heed his advice. Nor did they give a warm welcome to Kharash ibn Umayya, whom the Messenger sent after 'Urwa. Kharash was followed by 'Uthman ibn 'Affan, who had powerful relatives among the Quraysh. Although 'Uthman came to negotiate with the Makkans, they imprisoned him. When he did not return at the expected time, rumors circulated that he had been killed. At this point, the Prophet, sitting under a tree, took an oath from his Companions that they would hold together and fight to the death. He represented the absent 'Uthman by proxy in this oath. Only Jadd ibn Qays, who hid behind a camel, did not take it. The revelation that came on this occasion reads: God was well pleased with the believers when they were swearing allegiance to you under the tree, and He knew what was in their hearts, so He sent down peace of reassurance on them, and has rewarded them with a near victory (48:18).
In that moment of tension, a cloud of dust appeared in the distance. This turned out to be a Makkan delegation led by Suhayl ibn 'Amr. When the Messenger learned this, he took his name ("easiness") as a good omen and told his Companions: "The situation has eased." Eventually, the Quraysh agreed to a truce and the Treaty of Hudaybiya was concluded.
Under this treaty, the Prophet and his followers could make pilgrimage the following year, not this one, at which time the Makkans would vacate the city for 3 days The treaty also stipulated a 10-year truce, that people or tribes could join or ally themselves with whoever they wished, and that Qurayshi subjects or dependents who defected to Madina would be returned. This last condition was not reciprocal, and thus was opposed in the Muslim camp. It shocked people like 'Umar, who questioned the Messenger about it. However, it really was of little importance. Muslims sent back to Makka were not likely to renounce Islam; on the contrary, they would be agents of change within Makka.
Just before the treaty was signed, Abu Jandal, Suhayl's son, arrived in chains and asked to join the Muslims. The Messenger had to return him to his father in tears. However, he whispered to him: "God will shortly save you and those of your like." 
Shortly after the treaty was signed, 'Utba ibn Asid (also known as Abu Basir) defected to Madina. The Quraysh sent two men to demand his return. On their way back to Makka, Abu Basir escaped, killed one man and wounded the other. The Messenger, citing the treaty's terms, did not allow him to stay in Madina. So he settled at Iyss, a place on the road from Makka to Syria. The Muslims held in Makka began to join Abu Basir. As this settlement grew, the Makkans perceived a potential threat to their trade route. This forced them to ask the Messenger to annul the relevant term and admit defecting Makkans to Madina.
The Qur'an called the Treaty of Hudaybiya "a manifest victory": We have given you a manifest victory (48:1). This proved true for several reasons, among them:
• By signing this treaty after years of conflict, the Quraysh admited that the Muslims were their equals. In effect, they gave up their struggle but did not admit it to themselves. Seeing the Makkans deal with the Prophet as an equal and a ruler, a rising tide of converts flowed toward Madina from all over Arabia.
• Many Qurayshis would benefit from the resulting peace by finally reflecting on what was going on. Such leading Qurayshis as Khalid ibn Walid, 'Amr ibn al-'As, and 'Uthman ibn Talha, all famous for their military and political skills, accepted Islam. 'Uthman was the person entrusted with the Ka'ba's keys, and after the conquest of Makka the Messenger honored him with the same task.
• The Quraysh used to regard the Ka'ba as their exclusive property, and made its visitors pay them a tribute. By not subjecting the Muslims' deferred pilgrimage to this condition, the Quraysh unwittingly ended their monopoly. The bedouin tribes now realized that the Quraysh had no right to claim exclusive ownership.
• At the time, there were Muslim men and women living in Makka. Not everyone in Madina knew who they were. Some were serving the Messenger as spies. Had a fight taken place in Makka, the victorious Muslim army might have killed some of them. This would have caused great personal anguish, as well as the martyrdom or identification of the Prophet's spies. The treaty prevented such a disaster.
The Qur'an points to this fact: He restrained their hands from you, and your hands from them, in the hollow of Makka, after He made you victors over them. God sees the things you do. They are the ones who disbelieved, and banned you from the Holy Mosque, and hindered the sacrificial animals from reaching their place of sacrifice. If it had not been for certain believing men and believing women (in Makka) whom you knew not—lest you should trample them and thus incur guilt for them unknowingly; that God may admit into His Mercy whom He will—(the believers and unbelievers) had been clearly separated, then We would have chastised the unbelievers among them with a painful chastisement (48:24–25).
• The Prophet performed the minor pilgrimage the following year. The assertion: "There is no god but God, and Muhammad is the Messenger of God," rang throughout Makka. The Quraysh, camped on Abu Qubays Hill, heard this portent of Islam's coming triumph. This was, in fact, God's fulfilling the vision He had given to His Messenger: God has indeed fulfilled the vision He vouchsafed to His Messenger: You shall enter the Holy Mosque, if God wills, in security, your heads shaved, your hair cut short, not fearing. He knew what you knew not, and, granted, besides this, a nigh victory (48:27).
• The treaty allowed the Messenger to deal with others. In the post-treaty expeditions, the Muslims conquered the formidable Jewish citadels of Khaybar, telling them either to convert or accept Muslim rule by paying tribute in lieu of protection (jizya). Their neighbours, as well as other Arab tribes, were impressed with the Islamic state's growing strength.
The Muslims faithfully observed the treaty's terms; however, a tribe allied to the Makkans did not. The Banu Bakr attacked the Banu Khuda'a, who were allied with the Prophet. So in December 629, the Messenger marched a 10,000-man army against Makka, and captured it with almost no resistance on the first day of the new year. The Ka'ba was purified of idols and, over the next couple of days, the Makkans accepted Islam. This was due to happen because:
He has sent His Messenger with the guidance and the religion of truth, that He may uplift it above every religion. God suffices as a witness. Muhammad is the Messenger of God, and those who are with him are hard against the unbelievers, merciful to one another. You see them bowing, prostrating, seeking grace from God and (His) good pleasure. Their mark is on their faces, the trace of prostration. That is their likeness in the Torah, and their likeness in the Gospel is: as a seed that puts forth its shoot, and strengthens it, and it grows stout and rises straight upon its stalk, pleasing the sowers, that through them He may enrage the unbelievers. God has promised those of them who believe and do deeds of righteousness forgiveness and a mighty wage (48.28–29).
 Bukhari, 3:180; Ibn Hanbal, 4:324; Tabari, 3:75.
 Ibn Hisham, 3:321–333; Ibn Kathir, 4:188-193.