Their immorality led them to commit fornication right inside the Ka'bah Shareef. Allah's Wrath overtook them. Both were transformed into two rocks. Their tribes-people placed o¬ne rock o¬n Mount Safa and o¬ne o¬n Mount Marwah to serve as a lesson of Allah's curse and wrath. Others who would see these rocks would be overcome with fear and refrain from sin.
After an age had passed the ignorant people who had fallen into paganism, began worshipping these two rocks. They became idols of worship. Rasulullah (sallallahu alayhi wasallam) ordered these two rocks to be removed and thrown away in some remote place.