كتاب الحج
15  
The Book of Pilgrimage
(26)
Chapter: It is permissible to exit Ihram if one is prevented from completing Hajj; It is permissible to perform Qiran and the pilgrim performing Qiran should perform just one Tawaf and one Sa'i
(26)
باب بَيَانِ جَوَازِ التَّحَلُّلِ بِالإِحْصَارِ وَجَوَازِ الْقِرَانِ ‏
Sahih Muslim 1230 e

This hadith has been narrated from Ibn Umar through another chain of transmitters except with (this variation) that Allah's Apostle (ﷺ) was mentioned in the first part of the hadith,. i. e. when it was said to him:

They would bar you (from going) to the House. He said: In that, case I would do what Allah's Messenger (ﷺ) had done. He did not mention at the end of this hadith (i. e. these words):" This is how the Messenger of Allah (ﷺ) had done," as it Is narrated by al-Laith.
حَدَّثَنَا أَبُو الرَّبِيعِ الزَّهْرَانِيُّ، وَأَبُو كَامِلٍ قَالاَ حَدَّثَنَا حَمَّادٌ، ح وَحَدَّثَنِي زُهَيْرُ بْنُ، حَرْبٍ حَدَّثَنِي إِسْمَاعِيلُ، كِلاَهُمَا عَنْ أَيُّوبَ، عَنْ نَافِعٍ، عَنِ ابْنِ عُمَرَ، ‏.‏ بِهَذِهِ الْقِصَّةِ ‏.‏ وَلَمْ يَذْكُرِ النَّبِيَّ صلى الله عليه وسلم إِلاَّ فِي أَوَّلِ الْحَدِيثِ حِينَ قِيلَ لَهُ يَصُدُّوكَ عَنِ الْبَيْتِ ‏.‏ قَالَ إِذًا أَفْعَلَ كَمَا فَعَلَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏.‏ وَلَمْ يَذْكُرْ فِي آخِرِ الْحَدِيثِ هَكَذَا فَعَلَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏.‏ كَمَا ذَكَرَهُ اللَّيْثُ ‏.‏
Reference : Sahih Muslim 1230e
In-book reference : Book 15, Hadith 201
USC-MSA web (English) reference : Book 7, Hadith 2842
  (deprecated numbering scheme)