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.
bukhari:6992ʿAbdullāh > Jūwayriyah > Mālik > al-Zuhrī > Saʿīd b. al-Musayyab And ʾAbā ʿUbayd > Abū Hurayrah

Messenger of Allah ﷺ said, "If I stayed in prison as long as Joseph stayed and then the messenger came, I would respond to his call (to go out of the prison) ."  

البخاري:٦٩٩٢حَدَّثَنَا عَبْدُ اللَّهِ حَدَّثَنَا جُوَيْرِيَةُ عَنْ مَالِكٍ عَنِ الزُّهْرِيِّ أَنَّ سَعِيدَ بْنَ الْمُسَيَّبِ وَأَبَا عُبَيْدٍ أَخْبَرَاهُ عَنْ أَبِي هُرَيْرَةَ ؓ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ لَوْ لَبِثْتُ فِي السِّجْنِ مَا لَبِثَ يُوسُفُ ثُمَّ أَتَانِي الدَّاعِي لأَجَبْتُهُ  


See similar narrations below:

Collected by Bukhārī
bukhari:3387ʿAbdullāh b. Muḥammad b. Asmāʾ from my cousin Jūwayriyah > Jūwayriyah b. Asmāʾ > Mālik > al-Zuhrī > Saʿīd b. al-Musayyab And ʾAbā ʿUbayd > Abū Hurayrah

Messenger of Allah ﷺ said, "May Allah bestow His Mercy on Lot. He wanted to have a powerful support. If I were to stay in prison (for a period equal to) the stay of Joseph (prison) and then the offer of freedom came to me, then I would have accepted it." (See Hadith No. 591)  

البخاري:٣٣٨٧حَدَّثَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدِ بْنِ أَسْمَاءَ ابْنِ أَخِي جُوَيْرِيَةَ حَدَّثَنَا جُوَيْرِيَةُ بْنُ أَسْمَاءَ عَنْ مَالِكٍ عَنِ الزُّهْرِيِّ أَنَّ سَعِيدَ بْنَ الْمُسَيَّبِ وَأَبَا عُبَيْدٍ أَخْبَرَاهُ عَنْ أَبِي هُرَيْرَةَ ؓ قَالَ

قَالَ رَسُولُ اللَّهِ ﷺ يَرْحَمُ اللَّهُ لُوطًا لَقَدْ كَانَ يَأْوِي إِلَى رُكْنٍ شَدِيدٍ وَلَوْ لَبِثْتُ فِي السِّجْنِ مَا لَبِثَ يُوسُفُ ثُمَّ أَتَانِي الدَّاعِي لأَجَبْتُهُ