Language:
كتاب المغازى
64  
Military Expeditions led by the Prophet (pbuh) (Al-Maghaazi)
(43)
Chapter: ‘'Umra Al-Qada’
(43)
باب عُمْرَةُ الْقَضَاءِ
Sahih al-Bukhari 4252

Narrated Ibn `Umar:

Allah's Messenger (ﷺ) set out with the intention of performing `Umra, but the infidels of Quraish intervened between him and the Ka`ba, so the Prophet (ﷺ) slaughtered his Hadi (i.e. sacrificing animals and shaved his head at Al-Hudaibiya and concluded a peace treaty with them (i.e. the infidels) on condition that he would perform the `Umra the next year and that he would not carry arms against them except swords, and would not stay (in Mecca) more than what they would allow. So the Prophet (ﷺ) performed the `Umra in the following year and according to the peace treaty, he entered Mecca, and when he had stayed there for three days, the infidels ordered him to leave, and he left.

حَدَّثَنِي مُحَمَّدُ بْنُ رَافِعٍ، حَدَّثَنَا سُرَيْجٌ، حَدَّثَنَا فُلَيْحٌ، ح وَحَدَّثَنِي مُحَمَّدُ بْنُ الْحُسَيْنِ بْنِ إِبْرَاهِيمَ، قَالَ حَدَّثَنِي أَبِي، حَدَّثَنَا فُلَيْحُ بْنُ سُلَيْمَانَ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ ـ رضى الله عنهما أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم خَرَجَ مُعْتَمِرًا، فَحَالَ كُفَّارُ قُرَيْشٍ بَيْنَهُ وَبَيْنَ الْبَيْتِ، فَنَحَرَ هَدْيَهُ، وَحَلَقَ رَأْسَهُ بِالْحُدَيْبِيَةِ، وَقَاضَاهُمْ عَلَى أَنْ يَعْتَمِرَ الْعَامَ الْمُقْبِلَ، وَلاَ يَحْمِلَ سِلاَحًا عَلَيْهِمْ إِلاَّ سُيُوفًا، وَلاَ يُقِيمَ بِهَا إِلاَّ مَا أَحَبُّوا، فَاعْتَمَرَ مِنَ الْعَامِ الْمُقْبِلِ، فَدَخَلَهَا كَمَا كَانَ صَالَحَهُمْ، فَلَمَّا أَنْ أَقَامَ بِهَا ثَلاَثًا أَمَرُوهُ أَنْ يَخْرُجَ، فَخَرَجَ‏.‏
Reference : Sahih al-Bukhari 4252
In-book reference : Book 64, Hadith 287
USC-MSA web (English) reference : Vol. 5, Book 59, Hadith 554
  (deprecated numbering scheme)