Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
ahmad:3251ʿAbd al-Razzāq > Maʿmar > ʿUthmān al-Jazarī > Miqsam a freed slave of Ibn ʿAbbās

[Machine] Some of them, when morning came, kept watch over him [the Prophet] securely, desiring to kill him. And some of them said, "Rather, let us drive him out [of the city]." And Allah conveyed to His Prophet [knowledge of] their plan. So Ali, that night, slept on the Prophet's bed, while the Prophet left and hurried to the cave. The polytheists were guarding Ali, assuming he was the Prophet. When they realized their mistake in the morning, they raced towards him. But when they saw Ali, Allah deceived them with his likeness, and they said, "Where is your companion?" He said, "I do not know, so solve the problem for yourselves." When they reached the mountain, it crumbled upon them, and they ascended into it. They passed by the cave, and they saw the spider's web at its entrance. They said, "If someone had entered here, the spider's web would not be on its door. So he must have stayed in it for three nights."  

أحمد:٣٢٥١حَدَّثَنَا عَبْدُ الرَّزَّاقِ حَدَّثَنَا مَعْمَرٌ قَالَ وَأَخْبَرَنِي عُثْمَانُ الْجَزَرِيُّ أَنَّ مِقْسَمًا مَوْلَى ابْنِ عَبَّاسٍ أَخْبَرَهُ عَنِ ابْنِ عَبَّاسٍ

فِي قَوْلِهِ {وَإِذْ يَمْكُرُ بِكَ الَّذِينَ كَفَرُوا لِيُثْبِتُوكَ} [الأنفال 30] قَالَ تَشَاوَرَتْ قُرَيْشٌ لَيْلَةً بِمَكَّةَ فَقَالَ بَعْضُهُمْ إِذَا أَصْبَحَ فَأَثْبِتُوهُ بِالْوَثَاقِ يُرِيدُونَ النَّبِيَّ ﷺ وَقَالَ بَعْضُهُمْ بَلِ اقْتُلُوهُ وَقَالَ بَعْضُهُمْ بَلْ أَخْرِجُوهُ فَأَطْلَعَ اللهُ ﷻ نَبِيَّهُ عَلَى ذَلِكَ فَبَاتَ عَلِيٌّ عَلَى فِرَاشِ النَّبِيِّ ﷺ تِلْكَ اللَّيْلَةَ وَخَرَجَ النَّبِيُّ ﷺ حَتَّى لَحِقَ بِالْغَارِ وَبَاتَ الْمُشْرِكُونَ يَحْرُسُونَ عَلِيًّا يَحْسَبُونَهُ النَّبِيَّ ﷺ فَلَمَّا أَصْبَحُوا ثَارُوا إِلَيْهِ فَلَمَّا رَأَوْا عَلِيًّا رَدَّ اللهُ مَكْرَهُمْ فَقَالُوا أَيْنَ صَاحِبُكَ هَذَا؟ قَالَ لَا أَدْرِي فَاقْتَصُّوا أَثَرَهُ فَلَمَّا بَلَغُوا الْجَبَلَ خُلِّطَ عَلَيْهِمْ فَصَعِدُوا فِي الْجَبَلِ فَمَرُّوا بِالْغَارِ فَرَأَوْا عَلَى بَابِهِ نَسْجَ الْعَنْكَبُوتِ فَقَالُوا لَوْ دَخَلَ هَاهُنَا لَمْ يَكُنْ نَسْجُ الْعَنْكَبُوتِ عَلَى بَابِهِ فَمَكَثَ فِيهِ ثَلَاثَ لَيَالٍ  


See similar narrations below:

Collected by Ṭabarānī
tabarani:12155Muḥammad b. Hishām al-Mustamlī > ʿAlī b. al-Madīnī > ʿAbd al-Razzāq > Maʿmar > ʿUthmān al-Jazarī > Miqsam

[Machine] In His statement, "And [remember] when those who disbelieved plotted against you to restrain you or kill you or evict you [from Makkah]. But they plan, and Allah plans. And Allah is the best of planners." Quraysh consulted one night in Makkah. Some of them said, "Let's establish a case against him with evidence, seeking to discredit the Prophet ﷺ." Some of them said, "Kill him!" And some of them said, "Expel him!" Allah informed His Prophet ﷺ about this. Ali stayed in the bed of the Prophet ﷺ that night while the Messenger of Allah ﷺ left until he reached the cave. The polytheists guarded it, thinking he was the Prophet ﷺ. When they woke up in the morning, they went after him and when they saw Ali, Allah foiled their plan. They asked, "Where is your companion?" He replied, "I do not know." They searched for his footprints and when they reached the mountain, they became disoriented. They climbed the mountain and passed by the cave where they found spider webs covering its entrance. They stayed there for three [days].  

الطبراني:١٢١٥٥حَدَّثَنَا مُحَمَّدُ بْنُ هِشَامٍ الْمُسْتَمْلِيُّ ثنا عَلِيُّ بْنُ الْمَدِينِيِّ أَنَا عَبْدُ الرَّزَّاقِ أَنَا مَعْمَرٌ عَنْ عُثْمَانَ الْجَزَرِيِّ عَنْ مِقْسَمٍ عَنِ ابْنِ عَبَّاسٍ

فِي قَوْلِهِ {وَإِذْ يَمْكُرُ بِكَ الَّذِينَ كَفَرُوا لِيُثْبِتُوكَ} قَالَ §تَشَاوَرَتْ قُرَيْشٌ لَيْلَةً بِمَكَّةَ فَقَالَ بَعْضُهُمْ أَثْبِتُوهُ بِالْوَثَائِقِ يُرِيدُونَ النَّبِيَّ ﷺ وَقَالَ بَعْضُهُمْ اقْتُلُوهُ وَقَالَ بَعْضُهُمْ أَخْرِجُوهُ فَأَطْلَعَ اللهُ نَبِيَّهُ ﷺ عَلَى ذَلِكَ فَبَاتَ عَلِيٌّ عَلَى فِرَاشِ النَّبِيِّ ﷺ تِلْكَ اللَّيْلَةَ وَخَرَجَ رَسُولُ اللهِ ﷺ حَتَّى لَحِقَ بِالْغَارِ وَبَاتَ الْمُشْرِكُونَ يَحْرُسُونَ عَلِيًّا ؓ يَحْسِبُونَ أَنَّهُ النَّبِيُّ ﷺ فَلَمَّا أَصْبَحُوا ثَارُوا إِلَيْهِ فَلَمَّا رَأَوْا عَلِيًّا رَدَّ اللهُ مَكْرَهُمْ فَقَالُوا أَيْنَ صَاحِبُكَ؟ قَالَ لَا أَدْرِي فَاقْتَصُّوا أَثَرَهُ فَلَمَّا بَلَغُوا الْجَبَلَ اخْتَلَطَ عَلَيْهِمْ فَصَعِدُوا الْجَبَلَ فَمَرُّوا بِالْغَارِ فَإِذَا عَلَى بَابِهِ نسيجُ الْعَنْكَبُوتِ فَمَكَثَ فِيهِ ثَلَاثًا