Hazrat Zaid bin Haarithah (radhiyallahu ‘anhu) narrates:
During the era of ignorance (the period prior to Islam), when the disbelievers would perform tawaaf of the Ka‘bah, they would pass their hands over the idols Isaaf and Naa’ilah.
Once, I accompanied Rasulullah (sallallahu ‘alaihi wasallam) in performing tawaaf of the Baytullah. As we passed these idols, I passed my hand over them. Rasulullah (sallallahu ‘alaihi wasallam) forbade me from doing this. I thought to myself, “I will touch them again to see what Rasulullah (sallallahu ‘alaihi wasallam) will say.” Hence, I passed my hand over them again. Seeing this, Rasulullah (sallallahu ‘alaihi wasallam) said with sternness, “Did I not prohibit you?”
By Allah! From that day on, I never touched a single idol until the time when Allah Ta‘ala honored Rasulullah (sallallahu ‘alaihi wasallam) with prophethood and revealed His divine speech upon him (i.e. I never touched an idol until the end of my life).”
(Extracted from Seeratul Mustafa 1/118)