Abdullah bin Umar reported,

The Messenger of Allah ﷺ set out to perform Umrah, but the disbelievers of Quraysh stood between him and the House. So he sacrificed his offering and shaved his head at Hudaybiyyah, and he made a settlement with them on the condition that he would perform Umrah the following year, that he would not carry weapons against them except swords, and that he would not stay there longer than they wished.The following year he performed Umrah and entered Makkah according to the terms he had settled with them. When he had stayed there for three days, they instructed him to leave, and he departed.

Bukhari 4252

Sahih

حدثني محمد بن رافع حدثنا سريج حدثنا فليح ح و حدثني محمد بن الحسين بن إبراهيم قال حدثني أبي حدثنا فليح بن سليمان عن نافع

عن ابن عمر رضي الله عنهما

أن رسول الله ﷺ خرج معتمرا فحال كفار قريش بينه وبين البيت فنحر هديه وحلق رأسه بالحديبية وقاضاهم على أن يعتمر العام المقبل ولا يحمل سلاحا عليهم إلا سيوفا ولا يقيم بها إلا ما أحبوا فاعتمر من العام المقبل فدخلها كما كان صالحهم فلما أن أقام بها ثلاثا أمروه أن يخرج فخرج

البخاري 4252صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expeditions
Chapter
Amra of requital
Numbering
Darussalam 4252
Bukhari 4252