It is narrated from Sayyiduna Abu Dawud al-Mazini (may Allah be pleased with him), who was one of the people of Badr, that he said: We set out with the Messenger of Allah (peace and blessings be upon him). He (peace and blessings be upon him) entered the mosque of Dhu al-Hulayfah and prayed four rak'ahs in it; then he declared his intention (ihlal for Hajj/Umrah) in the mosque itself. Those who were in the mosque heard it and said: "He declared his intention from the mosque." Then he (peace and blessings be upon him) repeated the words of intention when he mounted his riding camel, and those who were near the mosque said: "He declared his intention after settling on his riding camel." Then, when he reached the level ground of al-Bayda, he repeated the words of intention there too, and those who were at al-Bayda heard it and said: "He declared his intention from al-Bayda." And all of them were speaking the truth.
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 14185