Bara bin Azib reported,

When the Prophet ﷺ intended to perform Umrah, he sent word to the people of Mecca seeking their permission to enter the city. They stipulated that he could stay no more than three nights, that he could enter only with weapons sheathed, and that he was not to call anyone from among them to follow him.Ali bin Abu Talib began writing the agreement between them, and he wrote, "This is what Muhammad, the Messenger of Allah, has settled upon."They objected, "If we knew you were the Messenger of Allah, we would not have prevented you and we would have pledged allegiance to you. Rather, write, 'This is what Muhammad bin Abdullah has settled upon.'"He said, "By Allah, I am Muhammad bin Abdullah, and by Allah, I am the Messenger of Allah."He himself did not write, so he said to Ali, "Erase 'Messenger of Allah.'"Ali said, "By Allah, I will never erase it."The Prophet ﷺ said, "Then show it to me."Ali showed it to him, and the Prophet ﷺ erased it with his own hand.After he had entered Mecca and the days had passed, the people of Mecca came to Ali and said, "Tell your companion to depart."Ali رضي الله عنه mentioned that to the Messenger of Allah ﷺ, who replied, "Yes," and then he departed.

Bukhari 3184

Sahih

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

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

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

البخاري 3184صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Jizya and truce
Chapter
Reconciliation for three days, or a known time
Numbering
Darussalam 3184
Bukhari 3184