It is narrated from Ibn Abbas (may Allah be pleased with him): “Ibrahim (peace be upon him) brought Hajar and her nursing infant, Ismail, and left them near a tree above Zamzam, close to the House of Allah. At that time, there was no one else in Makkah, nor was there any source of water there. Ibrahim (peace be upon him) left a container of dates and another of water and set out to return. Ismail’s mother followed him and said, ‘Where are you going, leaving us in this uninhabited land devoid of grass and vegetation?’ She repeated this to Ibrahim (peace be upon him) several times. Ibrahim continued forward without looking at her. She then asked, ‘Has Allah commanded you to do this?’ ‘Yes,’ Ibrahim (peace be upon him) replied. ‘Then Allah will not allow us to perish.’ Hajar returned, while Ibrahim continued onward. When he entered the narrow path between the two mountains, where no one could see him, he stood facing the House of Allah. Raising his hands, he supplicated, ‘O Allah! I have settled some of my descendants in an uncultivated valley near Your Sacred House. O Allah, so that they may establish the prayer. So make the hearts of people incline toward them, and provide them with fruits, so that they may give thanks.’[1] Ismail’s mother continued nursing him and drinking from that water herself. When the water in the container ran out, she became thirsty, and the child also became thirsty. Seeing the child suffering from thirst, she moved away so that she would not have to endure seeing him in that condition. She found Safa to be the nearest of the mountains. She climbed Safa and stood facing the valley to see whether anyone could be seen. When she saw no one, she descended from Safa. Upon reaching the valley, she lifted her gown and ran quickly like an exhausted person. She crossed the valley and then climbed Marwah. Standing on Marwah, she looked to see whether anyone could be seen. When she saw no one, she descended from Marwah. In this manner, she went between the two mountains seven times. Ibn Abbas (may Allah be pleased with him) said that the Messenger of Allah (ﷺ) said, ‘This is the reason people perform sa‘i between Safa and Marwah.’ While she was on Marwah, she heard a voice and said to herself, ‘Be quiet!’ She heard the voice again and said, ‘I have heard you, but tell me whether you have any relief to offer.’ She then saw an angel digging the ground at the site of Zamzam with his heel or his wing. Eventually, water emerged, and she began containing it like a reservoir. Ibn Abbas (may Allah be pleased with him) said that the Messenger of Allah (ﷺ) said, ‘May Allah have mercy on Ismail’s mother. Had she left Zamzam alone—or, according to another narration, had she not scooped up the water of Zamzam—Zamzam would have become a flowing spring.’
The angel said to Hajar, “Do not fear being lost, for here is the House of Allah, which this boy and his father will build. And Allah does not allow its people to perish.”[2]
[1] Surah Ibrahim: 37
[2] For the detailed account, see Sahih Bukhari: 1/474–475