The Messenger of Allah ﷺ prayed in that valley of Batha when he was returning from his pilgrimage. Then the Messenger of Allah ﷺ entered Madinah, made his camel kneel at the door of his mosque, went inside and prayed two rakahs, and then departed to his house.Nafi said, "Abdullah bin Umar used to do the same."
أن رسول الله ﷺ صلى حين أقبل من حجته قافلا في تلك البطحاء، قال: ثم دخل رسول الله ﷺ المدينة، فأناخ على باب مسجده، ثم دخل فركع فيه ركعتين، ثم انصرف إلى بيته. قال نافع: فكان عبد الله بن عمر كذلك يصنع.
It was narrated by Ahmad (6132) — and this is his wording —, and Abu Dawud (2782), from the route of Yaqub (who is Ibn Ibrahim bin Saad bin Ibrahim Zuhri), from his father, from Ibn Ishaq, who said, Nafi told me, from Ibn Umar, and he mentioned it. Its chain of transmission is hasan because of Muhammad bin Ishaq.Nawawi said, "These hadiths establish the recommendation of praying two rak'ahs in the masjid for someone returning from a journey, right upon his arrival. This prayer is intended for the return from travel, it is not the greeting prayer for the masjid. The hadiths mentioned are explicit in what I have stated, and they also show the recommendation of arriving in the early part of the day."