Ismail's mother began nursing Ismail and drinking from that water, until what was in the waterskin ran out. She became thirsty and her son became thirsty, and she began watching him writhing, or he said, tossing about. She walked away, unable to bear watching him, and found that Safa was the nearest hill in that area to her. She stood upon it and faced the valley, looking to see if she could see anyone, but she saw no one. So she descended from Safa, and when she reached the valley, she lifted the edge of her garment and ran with the running of an exhausted person until she crossed the valley. Then she came to Marwa and stood upon it, looking to see if she could see anyone, but she saw no one. She did this seven times.Ibn Abbas said, "The Prophet ﷺ said, 'That is why people perform the saee between them.'"
… وجعلت أم إسماعيل ترضع إسماعيل وتشرب من ذلك الماء، حتى إذا نفد ما في السقاء عطشت وعطش ابنها وجعلت تنظر إليه يتلوى- أو قال يتلبط- فانطلقت كراهية أن تنظر إليه فوجدت الصفا أقرب جبل في الأرض يليها فقامت عليه ثم استقبلت الوادي تنظر هل ترى أحدا؟ فلم تر أحدا فهبطت من الصفا حتى إذا بلغت الوادي رفعت طرف درعها، ثم سعت سعي الإنسان المجهود حتى جاوزت الوادي ثم أنت المروة فقامت عليها ونظرت هل ترى أحدا؟ فلم تر أحدا، ففعلت ذلك سبع مرات. قال ابن عباس: قال النبي ﷺ: فذلك سعي الناس بينهما.
Bukhari narrated it in the chapters on the prophets (3364), from Abdullah bin Muhammad (who is Jufi Musnadi), he said, Abdul-Razzaq narrated to us, Mamar informed us, from Ayub Sakhtiyani, and Kathir bin Kathir bin Muttalib bin Abu Wada, each adding to what the other said, from Saeed bin Jubayr, who said, Ibn Abbas said, and he mentioned the hadith in full.