Sayyiduna al-Bara' (may Allah be pleased with him) says: The Messenger of Allah (peace and blessings be upon him) intended to perform Umrah in Dhu al-Qa'dah. The people of Makkah refused, saying that the Muslims could not enter Makkah until an agreement was made, the agreement being that the Muslims would not stay more than three days. When the agreement was written, the scribe wrote: This is the agreement settled by Muhammad, the Messenger of Allah (peace and blessings be upon him). The idolaters said: If we accepted you as the Messenger of Allah, what would the dispute be about? You are not the Messenger of Allah; rather, you are Muhammad bin Abdullah. He (peace and blessings be upon him) said: "I am the Messenger of Allah, and I am also the son of Abdullah." And he said: "O Ali! Erase the words 'Messenger of Allah'." Sayyiduna Ali (may Allah be pleased with him) said: By Allah! I will never erase it. He (peace and blessings be upon him) took the document and wrote on it: This is the agreement settled by Muhammad bin Abdullah: that they will not enter Makkah with weapons, except a sword, and that too in its sheath; that no one from the people of Makkah will go with the Muslims; and that if any Muslim wishes to stay with the people of Makkah, leaving the Muslims, he will not be prevented. When the Muslims had entered Makkah and the term was completed, the people of Makkah came to Sayyiduna Ali (may Allah be pleased with him) and said: Tell your companion to leave this place now. So the Messenger of Allah (peace and blessings be upon him) set out from Makkah, and the daughter of Sayyiduna Hamzah (may Allah be pleased with him) followed him, calling out: O uncle! O uncle! Sayyiduna Ali (may Allah be pleased with him) took hold of her and handed her over to Sayyidah Fatimah (may Allah be pleased with her). Then Sayyiduna Ali, Sayyiduna Zayd and Sayyiduna Ja'far (may Allah be pleased with them) disputed over her. Sayyiduna Ali (may Allah be pleased with him) said: I took hold of her, and she is the daughter of my paternal uncle. Sayyiduna Ja'far (may Allah be pleased with him) said: She is the daughter of my paternal uncle too, and her maternal aunt is married to me. Sayyiduna Zayd (may Allah be pleased with him) said: She is my brother's daughter. The Messenger of Allah (peace and blessings be upon him) ruled in favour of her maternal aunt and said: "The maternal aunt is in the position of the mother." He said to Sayyiduna Ali (may Allah be pleased with him): "You are from me and I am from you." He said to Sayyiduna Ja'far (may Allah be pleased with him): "You resemble me in appearance and in character." And he said to Sayyiduna Zayd (may Allah be pleased with him): "O Zayd! You are our brother and our mawla."
Imam Bukhari (may Allah have mercy on him) recorded it in his Sahih from Ubaydullah bin Musa.
Likewise, Ubaydullah bin Musa narrated it from Isra'il in a mudraj (interpolated) form.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النفقات / 15768