Messenger of Allah ﷺ set out for the ʿUmra but the pagans of Quraish prevented him from reaching the Kaʿba. So, he slaughtered his sacrifice and got his head shaved at Al-Hudaibiya, and agreed with them that he would perform ʿUmra the following year and would not carry weapons except swords and would not stay in Mecca except for the period they allowed. So, the Prophet ﷺ performed the ʿUmra in the following year and entered Mecca according to the treaty, and when he stayed for three days, the pagans ordered him to depart, and he departed. (Using translation from Bukhārī 2701)
أَنَّ رَسُولَ اللهِ ﷺ خَرَجَ مُعْتَمِرًا فَحَالَ كُفَّارُ قُرَيْشٍ بَيْنَهُ وَبَيْنَ الْبَيْتِ فَنَحَرَ هَدْيَهُ وَحَلَقَ رَأْسَهُ بِالْحُدَيْبِيَةِ فَصَالَحَهُمْ عَلَى أَنْ يَعْتَمِرُوا الْعَامَ الْمُقْبِلَ وَلَا يَحْمِلَ السِّلَاحَ عَلَيْهِمْ َقَالَ سُرَيْجٌ وَلَا يَحْمِلَ سِلَاحًا إِلَّا سُيُوفًا وَلَا يُقِيمَ بِهَا إِلَّا مَا أَحَبُّوا فَاعْتَمَرَ مِنَ الْعَامِ الْمُقْبِلِ فَدَخَلَهَا كَمَا كَانَ صَالَحَهُمْ فَلَمَّا أَنْ أَقَامَ ثَلَاثًا أَمَرُوهُ أَنْ يَخْرُجَ فَخَرَجَ