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.
quran:16:110

Then, indeed your Lord, to those who emigrated after they had been compelled ˹to renounce their religion˺ and thereafter fought ˹for the cause of Allah˺ and were patient - indeed, your Lord, after that, is Forgiving and Merciful  

Then indeed your Lord — as for those who emigrated, to Medina, after they were persecuted, ˹after˺ they were tortured and ˹compelled to˺ pronounce ˹words of˺ unbelief (a variant reading ˹for futinū, ‘they were persecuted’˺ has fatanū, in other words, ‘˹after˺ they disbelieved’, or ‘˹after˺ they turned people away from belief’), and then struggled and were patient, in obedience — indeed your Lord after that, that is, ˹after˺ such a trial, is Forgiving, of them, Merciful, to them (the predicate of the first inna, ‘indeed’, is indicated by the predicate of the second one).
القرآن:١٦:١١٠

ثُمَّ إِنَّ رَبَّكَ لِلَّذِينَ هَاجَرُوا مِنْ بَعْدِ مَا فُتِنُوا ثُمَّ جَاهَدُوا وَصَبَرُوا إِنَّ رَبَّكَ مِنْ بَعْدِهَا لَغَفُورٌ رَحِيمٌ  

{ثم إن ربك للذين هاجروا} إلى المدينة {من بعد ما فُتنوا} عذبوا وتلفظوا بالكفر وفي قراءة بالبناء للفاعل أي كفروا أو فتنوا الناس عن الأيمان {ثم جاهدوا وصبروا} على الطاعة {إن ربك من بعدها} أي الفتنة {لغفور} لهم {رحيم} بهم وخبر إن الأولى دل عليه خبر الثانية.

See similar narrations below:

Collected by Qurʾān, Bayhaqī
quran:16:119

Then, indeed your Lord, to those who have done wrong out of ignorance and then repent after that and correct themselves - indeed, your Lord, thereafter, is Forgiving and Merciful.  

Then indeed your Lord — to those who did evil, associating others ˹with God˺, out of ignorance, and then repented, returned ˹to God’s way˺, after that and made amends, in their actions — indeed your Lord after that, that is, ˹after˺ that ignorance, or that repentance, is Forgiving, of them, Merciful, to them.
القرآن:١٦:١١٩

ثُمَّ إِنَّ رَبَّكَ لِلَّذِينَ عَمِلُوا السُّوءَ بِجَهَالَةٍ ثُمَّ تَابُوا مِنْ بَعْدِ ذَٰلِكَ وَأَصْلَحُوا إِنَّ رَبَّكَ مِنْ بَعْدِهَا لَغَفُورٌ رَحِيمٌ  

{ثم إن ربك للذين عملوا السوء} الشرك {بجهالة ثم تابوا} رجعوا {من بعد ذلك وأصلحوا} عملهم {إن ربك من بعدها} أي الجهالة أو التوبة {لغفور} لهم {رحيم} بهم.
bayhaqi:17757Abū ʿAbdullāh > Abū al-ʿAbbās > Aḥmad > Yūnus > Ibn Isḥāq > Ḥakīm b. Jubayr > Saʿīd b. Jubayr > Ibn ʿAbbās

Then, indeed your Lord, to those who emigrated after they had been compelled [to renounce their religion] and thereafter fought [for the cause of Allah] and were patient - indeed, your Lord, after that, is Forgiving and Merciful (Using translation from Qurʾān 16:110)   

البيهقي:١٧٧٥٧وَأَخْبَرَنَا أَبُو عَبْدِ اللهِ ثنا أَبُو الْعَبَّاسِ ثنا أَحْمَدُ ثنا يُونُسُ عَنِ ابْنِ إِسْحَاقَ حَدَّثَنِي حَكِيمُ بْنُ جُبَيْرٍ عَنْ سَعِيدِ بْنِ جُبَيْرٍ عَنِ ابْنِ عَبَّاسٍ ؓ قَالَ

أُنْزِلَتْ هَذِهِ الْآيَةُ فِيمَنْ كَانَ يُفْتَنُ مِنْ أَصْحَابِ رَسُولِ اللهِ ﷺ بِمَكَّةَ {ثُمَّ إِنَّ رَبَّكَ لِلَّذِينَ هَاجَرُوا مِنْ بَعْدِ مَا فُتِنُوا ثُمَّ جَاهَدُوا وَصَبَرُوا إِنَّ رَبَّكَ مِنْ بَعْدِهَا لَغَفُورٌ رَحِيمٌ} [النحل 110]