Abraham took Hagar and her son, Ishmael, to a place near the Ka’bah. There, he left them under a tree at the future site of Zamzam. No one lived in Makkah back then, yet Abraham left them sitting there only with some dates and a small water-skin. Thereafter he set out back towards his home. Ishmael’s mother followed him saying, “O Abraham! Where are you going? There is no person whose company we may enjoy, nor is there anything to take pleasure in.” She repeated that to him many times, but he did not look back at her. Then she asked him, “Has Allah ordered you to do this?” Only then did he turn back to her, replying, “Yes.” She said, “In that case, He will not abandon us.” Abraham proceeded onwards, and upon reaching a hill where they could not see him, he faced the Ka’bah and invoked Allah saying:
Our Lord, I have settled some of my descendants in an uncultivated valley near Your Sacred House. Our Lord, that they may establish prayer. So make hearts among the people incline toward them and provide for them from the fruits that they might be grateful. (14:37)
Hagar suckled Ishmael and drank from the water she had. When the water finished, she and her child increasingly became thirsty. Unsure of what to do next, she saw her child in agony while he cried. So she rushed to the nearest hill, which was the hill of Safaa. She stood there and looked intensely, hoping that she might see someone, but she could not see anyone. She then descended and once she reached the valley, she tucked up her robe and ran across the valley distressed, until she reached the hill of Marwaa. She gazed attentively, hoping to see someone, but she could not. She repeated this seven times.
Ibn Ab’bas said: “... She ascended the Safa mountain and looked, hoping to see somebody, but in vain. When she came down to the valley, she ran till she reached the hill of Marwa. She ran between the two hills many times. Then, she said to herself, ‘I'd better go and see the state of the child.’ When she went, she found him on the verge of dying. She could not endure to watch him dying and said, ‘If I go and look, I may find someone.’ She then ascended the hill of Safa again and looked for a long while, but could not find anybody. Thus she completed seven circuits (of running) between Safa and Marwa. Again she said, ‘I'd better go back and see the state of the child.’ But suddenly she heard a voice, and she replied to that strange voice, ‘Help us if you can offer any help.’ Lo! It was the voice of Gabriel. Gabriel hit the earth with his heel like this (Ibn `Abbas hit the earth with his heel to Illustrate it), and water gushed out. Ishmael's mother was astonished and started digging (to form a well around the source of the water).”
The Prophet said, “If she had left the water, to flow naturally without her intervention, it would have been flowing on the surface of the earth." Ishmael's mother started drinking from the water and her milk increased for her child. Afterward, some people of the tribe of Jurhum, while passing through the bot tom of the valley, saw some birds, and that astonished them. They said, “Birds can only be found at a place where there is water.” They sent a messenger who searched the place and found the water, and returned to inform them about it. Then they all went to her and said, “O Ismael’s mother! Will you allow us to remain here with you?” To which she agreed, and thus they stayed there. (Bukhari)