It is narrated from Ibn Abbas (may Allah be pleased with him) that he said: The Messenger of Allah (peace and blessings of Allah be upon him) said,
«لَمَّا أَتَى إِبْرَاهِيمُ خَلِيلُ اللَّهِ عَلَيْهِ السَّلاَمُ الْمَنَاسِكَ عَرَضَ لَهُ الشَّيْطَانُ عِنْدَ جَمْرَةِ الْعَقَبَةِ فَرَمَاهُ بِسَبْعِ حَصَيَاتٍ حَتَّى سَاخَ فِى الأَرْضِ ثُمَّ عَرَضَ لَهُ عِنْدَ الْجَمْرَةِ الثَّانِيَةِ فَرَمَاهُ بِسَبْعِ حَصَيَاتٍ حَتَّى سَاخَ فِى الأَرْضِ ثُمَّ عَرْضَ لَهُ فِى الْجَمْرَةِ الثَّالِثَةِ فَرَمَاهُ بِسَبْعِ حَصَيَاتٍ حَتَّى سَاخَ فِى الأَرْضِ. قَالَ ابْنُ عَبَّاسٍ رَضِىَ اللَّهُ عَنْهُ : الشَّيْطَانَ تَرْجُمُونَ وَملةَ أَبِيكُمْ تَتَّبِعُونَ».
‘When Ibrahim Khalilullah (peace be upon him) was performing the rites of Hajj, Satan appeared before him near Jamarat al-Aqabah. He pelted Satan with seven stones, causing him to sink into the ground. Then he appeared again at the second Jamarah. He again pelted him with seven stones, causing him to sink into the ground. Then he appeared again at the third Jamarah. He again pelted him with seven stones, causing him to sink into the ground. Ibn Abbas (may Allah be pleased with him) said: You pelt Satan with stones and follow the religion of your father Ibrahim.’[1]
However, it should never be thought that those who throw stones today are striking Satan; rather, following the Messenger of Allah (peace and blessings of Allah be upon him), we throw pebbles in order to exalt the remembrance of Allah. The Messenger of Allah (peace and blessings of Allah be upon him) said,
« إِنَّمَا جُعِلَ الطَّوَافُ بِالْبَيْتِ وَبَيْنَ الصَّفَا وَالْمَرْوَةِ وَرَمْىُ الْجِمَارِ لإِقَامَةِ ذِكْرِ اللَّه»
‘The rites of performing Tawaf around the House of Allah, performing Sa‘i between Safa and Marwah, and throwing stones at the Jamarat have been prescribed for the purpose of establishing the remembrance of Allah.’[2]
[1]. Sahih al-Targhib wa al-Tarhib: 6511.
[2]. Tirmidhi: 902; Jami‘ al-‘Ulum: 1505.