It was narrated that Ibn 'Abbas said, concerning the verse,
“And (remember) when the disbelievers plotted against you (O Muhammad (ﷺ)) to imprison you” (al-Anfal 8:30): Quraish discussed one night in Makkah. Some of them said: When morning comes, chain him up - referring to the Prophet (ﷺ). Others said: Rather you should kill him. And others said: Rather you should expel him. Allah, may He be glorified and exalted, informed His Prophet (ﷺ) about that, so ‘Ali slept in the bed of the Prophet (ﷺ) that night, and the Prophet (ﷺ) set out until he reached the cave, And the mushrikeen stayed lying in wait for 'Ali all night, thinking that he was the Prophet (ﷺ). When morning came, they entered upon him, and when they saw ‘Ali and (realized that) Allah had foiled their plot, they said: Where is your companion? He said: I do not know. They tried to track him down, but when they reached the mountain, they got confused. They climbed up the mountain and passed by the cave, but they saw a spider web over its entrance and said. If he entered here, there would not be a spider web over the entrance. And he stayed there for three nights.