The Messenger of Allah ﷺ set out from Medina heading to Mecca and was fasting until he reached Usfan. Then he called for water, raised it up in his hands so the people could see, and broke his fast. He remained not fasting until he arrived in Mecca. This took place during Ramadan.Ibn Abbas used to say, "The Messenger of Allah ﷺ both fasted and broke his fast on this journey, so whoever wishes may fast, and whoever wishes may break his fast."
خرج رسول الله ﷺ من المدينة إلى مكة، فصام حتى بلغ عسفان، ثم دعا بماء، فرفعه إلى يديه يريه الناس، فأفطر حتى قدم مكة. وذلك في رمضان. فكان ابن عباس يقول: قد صام رسول الله ﷺ وأفطر، فمن شاء صام، ومن شاء أفطر.
Bukhari narrated it in the Book of Fasting (1948), and Muslim in the Book of Fasting (1113), both from the hadith of Jareer, from Mansur, from Mujahid, from Tawus, from Ibn Abbas, who mentioned it.