Prophet Muhammad (pbuh) and the emigrants missed their homeland, which they had left five years earlier to protect their religion and to save their lives. They greatly desired to visit the Kaaba, which is the temple of the divine religion based on monotheism, as emphasized in various verses of the Quran. Eventually Prophet Muhammad decided to go to Mecca al-Mukarrama and perform a lesser pilgrimage when he had a dream in which he was circumambulating the Kaaba. He ordered his companions to prepare for the umrah. He assigned Abdullah ibn Ummu Maktum to lead the prayers, and appointed Numayla ibn Abdullah al-Laysi as his proxy to rule the city. He set out for Mecca from Medina in Dhu al-Qi'dah 6 (March 628) with 1,400-1,500 companions. The Muslims intended to perform the umrah wearing their ihram clothing and they took seventy camels for sacrifice. They were only equipped with their traveling swords as weapons, as their intentions were peaceful. The Prophet and his Companions camped in Hudaibiyah, which was 17 km from Mecca. Upon being informed that the Muslims were approaching, the Quraishis sent off a cavalry unit of 200 men, led by Khalid ibn al-Walid, to the region, even though they knew that Muslims only intended to visit the Kaaba. Prophet Muhammad sent Hirash ibn Umayya to the Quraishis as an emissary to explain the purpose of their arrival. However, Hirash ibn Umayya was not welcomed and the Quraishis wanted to kill him. Upon this, the Prophet sent Uthman as an emissary as Uthman had many relatives in the Quraishi tribe, particularly Abu Sufyan. Uthman entered Mecca under the protection of Aban ibn Said ibn As and told the Quraishis that their purpose was to perform the umrah, not to fight. The Quraishis told Uthman that they would not allow the Muslims to enter Mecca but that he could circumambulate the Kaaba if he so desired. Uthman said "I will not circumambulate the Kaaba unless the Prophet circumambulates first", and refused their offer. Upon hearing these words the Quarishis then arrested Uthman. When there was a delay in Uthman's returning from Mecca, a rumor spread through the Muslim camp that Uthman had been killed by the Quraishis of Mecca. This considerably upset the Muslims. At this juncture, the Prophet asked his companions to make a pledge with him to fight in the way of Allah to the bitter end. All the Muslims responded enthusiastically to the call. Prophet Muhammad sat under a tree and all the Muslims in the camp took the pledge one by one. After everybody had taken the pledge, the Prophet placed his own right hand on his left hand, and took the pledge on behalf of Uthman. Uthman thus secured the unique honor of having the Prophet take the pledge on his behalf. After this ceremony at Hudaibiyah, it was revealed: "Surely, Allah was pleased with the believers when they took the pledge under the tree. Allah knew what was in their hearts. He sent down tranquility upon them, and rewarded them with near victory" (Al-Fath 48/18) In view of Allah's pleasure at the pledge, the pledge came to be known as "Baiy'at-ur-Ridwan" and "Baiy'at-us-Shajara as it was done under a desert tree known as the samura. The Companions came to be known as Ashab us-Shajara (The one who took pledge under the tree).
The Quraishis were worried when they saw the loyalty of the Muslims towards the Prophet and their determination to fulfill his orders, even to the death. First they released Uthman and sent a delegation led by Suhayl ibn Amr to the Prophet to make peace. After the negotiations, Ali wrote the text of the treaty and it was signed by the Prophet and Suhayl ibn Amr. The treaty was witnessed by Abu Bakr, Umar, Uthman, Abdurrahman ibn Avf, Sa'd ibn Abu Vakkas, Abu Ubayda ibn Jarrah and Muhammad ibn Maslama from the Muslim party and Mikradz ibn Hafs, Suhayl ibn Amr, and Khuwaytib ibn Abduluzza from the idolater party. Both parties agreed to lay down the burden of war for ten years. During this time, each party was to be safe, and neither would injure the other; no secret damage was to be inflicted, but uprightness and honor would prevail between them. The Muslims were to return this year without performing the lesser pilgrimage. In the following year they were to enter, staying for three days, and bearing no arms except the arms of the traveler, with their swords remaining in their sheaths. If a Quraishi person were to approach a Muslim without the permission of his guardian, the Muslims should return this person, but if one of the Muslims were to come to the Quraishi, he was not to be returned. Whoever wished to enter into a covenant with the Muslims could do so, and whoever wished to enter into a covenant with the Quraishi could do so. On the face of it the Treaty of Hudaibiyah appeared to be loaded in favor of the Quraishis. Some of the Muslims, particularly Umar, felt dissatisfied with the terms of the treaty and gave expression to their dissatisfaction. However, they pronounced their loyalty when the Prophet stated that he had accepted the terms of the treaty. Prophet Muhammad (pbuh) and his Companions stayed in Hudaibiyah for twelve or twenty days. After signing the treaty, they sacrificed the camels as they had come to perform umrah and they returned to Medina later on.
Prophet Muhammad took care to comply with the terms of the treaty. For instance, Suhayl ibn Amr's son Abu Jandal was chained by his father because he had accepted Islam and he had been in prison for several years at that time. When the document was being written, Abu Jandal somehow managed to escape to Mecca, came to Hudaibiyah and he implored the Muslims to help secure his release from imprisonment. The Prophet said that the treaty had not been signed when Suhayl ibn Amr had desired the return of his son Abu Jandal. However, Suhayl said that he would not sign the treaty if they did not give his son back to him. Upon this, Prophet Muhammad had to return Abu Jandal to his father. Although Suhayl promised not to torture his son, he started to drag Abu Jandal in front of the Muslims. The Prophet and his Companions were deeply sorrowed by this scene. This sad incidence was called the Yawmu Abu Jandal (Abu Jandal Day) as a heartrending memory. On the other hand, the Prophet did not return two women who had taken shelter with the Muslims, asserting that the treaty only mentioned male immigrants. The Quraishis had to accept this. After the Prophet had returned to Medina, Abu Basir escaped to the Muslims. He had been imprisoned in Mecca. The Quraishis requested his return, sending two guards in accordance with the treaty. Although he resisted, the Prophet told Abu Basir that he had to go back, , but he advised Basir to be patient and that Allah would show him and the other Muslims who were in such a helpless position a way to be relieved. On their way back to Mecca, Abu Basir fled from the guards and came back to Medina. Fearing that the Muslims would again return him to the Quraishis, he left Medina and settled in Is or the Sifulbahr region on the Mecca-Syria trade route. Other new Muslims who could not enter Medina due to the treaty joined him there. In time, their numbers reached seventy or three hundred. They began to threaten trade caravans that belonged to the Quraishis. After these developments, the Quraishis wanted to invalidate the article of the treaty which stated: "If a Quraishi person comes to Muslims without the permission of his guardian, the Muslims shall return him to them." The Prophet sent a letter to Abu Basir and his friends, ordering them to come to Medina. However, Abu Basir was dying when the letter arrived. Abu Jandal and his friends buried Abu Basir and built a masjid next to his tomb. They went to Medina afterward.
The Treaty of Hudaibiyah is a turning point in Islamic history. Prophet Muhammad's aim was to dissolve the enemy alliance that had staged a siege on Medina during the Battle of the Trench. With this treaty, the Quraishis became neutral, enabling the Muslims to march on Khaybar after Hudaibiyah. Moreover, the hostility of the Quraishis against the Muslims ended; the Quraishi idolaters, who did not accept the Muslims and did not consider them as collocutors, accepted them as equals now. This result paved the way for both idolater tribes and Muslim tribes to contact the Prophet easily, and the invitation to Islam reached them freely. As a matter of fact, Islam spread rapidly in the Arabian Peninsula after this date; the number of people who became Muslims in the two years between the Treaty of Hudaibiyah and the Conquest of Mecca exceeded the number of people who had become Muslims in the previous eighteen years. Furthermore, it became possible to send invitational letters about Islam to the leaders of neighboring states. The Treaty of Hudaibiyah was not seen as a favorable treaty at the beginning, but it was the greatest political success of the Prophet, and was confirmed by the Holy Quran. The 48th verse of the Quran, sent in relation to this treaty, was called al-Fath; the treaty became known as fath al-mubin (a clear conquest) and nasr al-aziz (a glorious victory) (al-Fath 48/1, 3). The Prophet came to Mecca one year later and performed the lesser pilgrimage with his companions.