When the Prophet ﷺ intended to perform the ʿUmra he sent a person to the people of Mecca asking their permission to enter Mecca. They stipulated that he would not stay for more than three days and would not enter it except with sheathed arms and would not preach (Islam) to any of them. So ʿAli bin Abi- Talib started writing the treaty between them. He wrote, "This is what Muhammad, Apostle of Allah has agreed to." The (Meccans) said, "If we knew that you (Muhammad) are the Messenger of Allah, then we would not have prevented you and would have followed you. But write, 'This is what Muhammad bin ʿAbdullah has agreed to..' " On that Messenger of Allah ﷺ said, "By Allah, I am Muhammad bin ʿAbdullah, and, by Allah, I am Apostle of 'Allah." Messenger of Allah ﷺ used not to write; so he asked ʿAli to erase the expression of Apostle of Allah. On that ʿAli said, "By Allah I will never erase it." Allah's Apostle said (to ʿAli), "Let me see the paper." When ʿAli showed him the paper, the Prophet ﷺ erased the expression with his own hand. When Messenger of Allah ﷺ had entered Mecca and three days had elapsed, the Meccans came to ʿAli and said, "Let your friend (i.e. the Prophet) quit Mecca." ʿAli informed Messenger of Allah ﷺ about it and Messenger of Allah ﷺ said, "Yes," and then he departed. (Using translation from Bukhārī 3184)
أَنَّ النَّبِيَّ ﷺ لَمَّا أَرَادَ أَنْ يَعْتَمِرَ أَرْسَلَ إِلَى أَهْلِ مَكَّةَ يَسْتَأْذِنُهُمْ لِيَدْخُلَ مَكَّةَ فَاشْتَرَطُوا عَلَيْهِ أَنْ لَا يُقِيمَ بِهَا إِلَّا ثَلَاثَ لَيَالٍ وَلَا يَدْخُلَهَا إِلَّا بِجُلُبَّانِ السِّلَاحِ وَلَا يَدْعُو مِنْهُمْ أَحَدًا قَالَ فَأَخَذَ يَكْتُبُ الشَّرْطَ بَيْنَهُمْ عَلِيُّ بْنُ أَبِي طَالِبٍ ؓ كَتَبَ هَذَا مَا قَاضَى عَلَيْهِ مُحَمَّدٌ رَسُولُ اللهِ فَقَالُوا لَوْ عَلِمْنَا أَنَّكَ رَسُولُ اللهِ لَمْ نَمْنَعْكَ وَلَبَايَعْنَاكَ وَلَكِنِ اكْتُبْ هَذَا مَا قَاضَى عَلَيْهِ مُحَمَّدُ بْنُ عَبْدِ اللهِ فَقَالَ أَنَا وَاللهِ مُحَمَّدُ بْنُ عَبْدِ اللهِ وَأَنَا وَاللهِ رَسُولُ اللهِ قَالَ وَكَانَ لَا يَكْتُبُ قَالَ فَقَالَ لِعَلِيٍّ امْحُ رَسُولَ اللهِ قَالَ عَلِيٌّ لَا وَاللهِ لَا أَمْحَاهُ أَبَدًا قَالَ فَأَرِنِيهِ قَالَ فَأَرَاهُ إِيَّاهُ فَمَحَاهُ النَّبِيُّ ﷺ بِيَدِهِ فَلَمَّا دَخَلَ وَمَضَى الْأَجَلُ أَتَوْا عَلِيًّا ؓ فَقَالُوا مُرْ صَاحِبَكَ فَلْيَرْتَحِلْ فَذَكَرَ ذَلِكَ عَلِيٌّ لِرَسُولِ اللهِ ﷺ قَالَ نَعَمْ أَرْتَحِلُ