Allah Almighty says: "And complete the Hajj and Umrah for Allah. But if you are prevented (on the way), then (offer) whatever sacrificial animal is easily available, and do not shave your heads until the sacrificial animal reaches its place. And whoever among you is ill or has an ailment of the head, then (he must give) a ransom of fasting, or charity, or a sacrifice." [Surah al-Baqarah: 196]
Imam al-Shafi'i (may Allah have mercy on him) said: "I have not heard any of the scholars of tafsir from whom I have preserved (knowledge) differ on the fact that this verse was revealed at al-Hudaybiyah, when the Prophet (peace and blessings be upon him) was prevented and the polytheists came between him (peace and blessings be upon him) and the House (of Allah); and that the Prophet (peace and blessings be upon him) offered his sacrifice at al-Hudaybiyah itself and shaved his head, and he (peace and blessings be upon him) returned having exited ihram; he (peace and blessings be upon him) did not reach the House, nor did his (peace and blessings be upon him) Companions, except Sayyiduna Uthman bin Affan (may Allah be pleased with him), who reached it alone."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / Q10074
Sayyiduna Ka'b bin Ujrah (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) saw Ka'b bin Ujrah (may Allah be pleased with him) while lice were falling from his head onto his face. He (peace and blessings be upon him) asked: "Are they troubling you?" Ka'b (may Allah be pleased with him) said: "Yes." So he (peace and blessings be upon him) ordered him to shave his head. The narrator said: They were at al-Hudaybiyah; it had not been made clear to them that they would exit ihram there, and they were hoping to enter Makkah. Then Allah Almighty revealed the ransom (fidyah), and the Messenger of Allah (peace and blessings be upon him) ordered him to give one faraq (sixteen ratls, or three sa's) of food to six poor people, or to fast for three days, or to sacrifice a goat.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / 10074
Nafi' (may Allah have mercy on him) said: Abdullah bin Umar (may Allah be pleased with him) set out for Umrah during the time of the fitnah (civil strife) and said: If I am prevented from the House, then we will do as we did with the Messenger of Allah (peace and blessings be upon him). Abdullah bin Umar (may Allah be pleased with him) set out, having entered ihram for Umrah, and travelled until he climbed onto al-Bayda'. Then he turned to his companions and said: The matter of these two (Hajj and Umrah) is one and the same; I call you to witness that I have made Hajj obligatory upon myself along with Umrah. Then Abdullah bin Umar (may Allah be pleased with him) came to the House and performed tawaf, and the sa'y between Safa and Marwah, seven circuits each, and did no more than that. He held that this would suffice him, and he offered a sacrifice.
(b) In the narration of Ibn Bukayr: He entered ihram for Umrah because the Messenger of Allah (peace and blessings be upon him) had entered ihram for Umrah in the year of al-Hudaybiyah.
(c) Imam al-Shafi'i (may Allah have mercy on him) said: If we are prevented from the House, we will do as the Messenger of Allah (peace and blessings be upon him) did, that is, we will exit ihram just as we exited ihram with the Messenger of Allah (peace and blessings be upon him) in the year of al-Hudaybiyah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / 10075
Sayyiduna al-Miswar bin Makhramah (may Allah be pleased with him) and Marwan bin al-Hakam (may Allah have mercy on him), each of whose narrations confirms the other's, both said: The Messenger of Allah (peace and blessings be upon him) set out in the year of al-Hudaybiyah with more than a thousand of his Companions. When he (peace and blessings be upon him) came to Dhu al-Hulayfah, he garlanded his sacrificial animals there and marked them (ish'ar: slitting the camel's hump on the right side so that it is known as a sacrificial animal), and entered ihram for Umrah. (The narrator) mentioned his (peace and blessings be upon him) camping at the far edge of al-Hudaybiyah, then the coming of Suhayl bin Amr, and the terms that were settled with him when they prevented him from the House. When he (peace and blessings be upon him) had finished with the treaty, he said to his Companions: "Get up, slaughter your sacrifices, then shave your heads." The narrator said: By Allah, not a single one of them got up, until he (peace and blessings be upon him) had said it three times. When none of them got up, he went in to Umm Salamah (may Allah be pleased with her) and mentioned to her what he had met with from the people. Umm Salamah (may Allah be pleased with her) said: O Messenger of Allah (peace and blessings be upon him), would you like that (they do it)? Go out, then do not speak a word to any of them until you have slaughtered your sacrificial camels and called your barber to shave your head. So he (peace and blessings be upon him) got up and went out, and did not speak to any of them until he had done that: he slaughtered his sacrifice and called his barber, who shaved his head. When the people saw that, they got up and slaughtered their sacrifices, and began shaving one another's heads, until they almost killed one another out of grief.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / 10076
Marwan bin al-Hakam and al-Miswar bin Makhramah (may Allah be pleased with him) mentioned the long hadith, and in the account of his camping at al-Hudaybiyah added: His (peace and blessings be upon him) tent was in the Hill (outside the sanctuary), and he used to pray in the Haram. And in the words of Umm Salamah (may Allah be pleased with her) he added that she said: O Messenger of Allah (peace and blessings be upon him), do not blame them, for a very great matter has come upon the people, because they saw that you took upon yourself (hard terms) in the truce and that you are returning without victory. O Messenger of Allah, go out and do not speak to anyone among the people until you come to your sacrificial animal, slaughter it and exit ihram. When the people see that you have done this, they will do just as you (peace and blessings be upon him) have done. So he (peace and blessings be upon him) went out from Umm Salamah (may Allah be pleased with her), spoke to no one until he came to his sacrificial animal and slaughtered it, and shaved his head. When the people saw that the Messenger of Allah (peace and blessings be upon him) had done this, they got up and did the same: they slaughtered their sacrifices, and some shaved their heads and some shortened their hair. The Messenger of Allah (peace and blessings be upon him) said: "O Allah, forgive those who shaved their heads." He said it three times. It was said: O Messenger of Allah (peace and blessings be upon him), and those who shortened their hair? The Messenger of Allah (peace and blessings be upon him) said: "O Allah, forgive those who shaved their heads," three times. It was said: O Messenger of Allah, and those who shortened their hair? He (peace and blessings be upon him) said: "And those who shortened their hair too." Then the Messenger of Allah (peace and blessings be upon him) turned back.
(b) It was said to Ibn Abbas (may Allah be pleased with him): Why did the Messenger of Allah (peace and blessings be upon him) supplicate three times for those who shaved, but only once for those who shortened? He said: Because they did not doubt.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الحج / 10077