Six years had already elapsed since the Prophet and his Meccan followers had fled from their birthplace. Their hearts began to yearn for their homes and for their Sacred House the Kaba. As the season of the pilgrimage approached, the Prophet announced his intention to visit the holy center, and numerous voices of his disciples responded to the call. Preparations were soon made for the journey to Mecca. The Prophet, accompanied by seven or eight hundred Muslims, Emigrants and Ansars, all totally unarmed, set out on the pilgrimage. The Quraish, who were still full of animosity towards the Muslims, gathered a large army to prevent them from entering Mecca and maltreated the envoy whom the Prophet had sent to ask their permission to visit the holy places.
After much difficulty, a treaty was concluded by which it was agreed that all hostilities should cease for ten years; that any one coming from the Quraish to the Prophet without the permission of the guardian or chief should be given back to the idolaters; that any Muslim persons going over to the Meccans should not be surrendered; that any tribe desirous of entering into alliance, either with the Quraish or with the Muslims, should be at liberty to do so without disputes; that the Muslims should go back to Medina on the present occasion and stop advancing further; that they should be permitted in the following year to visit Mecca and to remain there for three days with the arms they used on journeys, namely, their scimitars in sheaths. The Treaty of Hudaibiya thus ended, the Prophet returned with his people to Medina.