I asked Anas bin Malik, "Did you used to dislike going between Safa and Marwa?"He replied, "Yes, because it was one of the rites of the days of ignorance, until Allah revealed, 'Indeed, Safa and Marwa are among the rites of Allah. So whoever performs the Hajj to the House or performs the lesser pilgrimage commits no wrong in going between them' [Baqarah 2:158]."
قلت لأنس بن مالك: أكنتم تكرهون السعي بين الصفا والمروة؟ قال: نعم لأنها كانت من شعائر الجاهلية حتى أنزل الله: {إن الصفا والمروة من شعائر الله فمن حج البيت أو اعتمر فلا جناح عليه أن يطوف بهما}.
Bukhari related it in the book of Hajj (1648), and Muslim in the book of Hajj (1278), both through the route of Asim (he is Ibn Sulayman al-Ahwal), with this wording, and the wording given is Bukhari's.The statement of Allah Most High, "Indeed, Safa and Marwa are among the rites of Allah" [Baqarah 2:158], indicates that going back and forth between them during the sa'i is an obligatory matter that cannot be dispensed with, because the rites of Allah are of great weight and it is not permissible to treat them lightly. Bukhari pointed to this in his Sahih when he said, "Chapter on the obligation of Safa and Marwa, and their being made among the rites of Allah."Ibn Hajar said, quoting from Ibn al-Munayyir, "The obligation of the sa'i is derived from the fact that the two of them were made among the rites of Allah."