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:17:80

And say, "My Lord, cause me to enter a sound entrance and to exit a sound exit and grant me from Yourself a supporting authority."  

And say: ‘My Lord, make me enter, Medina, with a veritable entrance, an entrance that is satisfying, one in which I do not see what I dislike, and bring me out, of Mecca, with a veritable departure, a departure such that my heart will not ˹care to˺ turn back to look at it ˹yearningly˺. And grant me from Yourself a favourable authority’, ˹grant me˺ strength with which You render me victorious over Your enemies.
القرآن:١٧:٨٠

وَقُلْ رَبِّ أَدْخِلْنِي مُدْخَلَ صِدْقٍ وَأَخْرِجْنِي مُخْرَجَ صِدْقٍ وَاجْعَلْ لِي مِنْ لَدُنْكَ سُلْطَانًا نَصِيرًا  

{وقل ربِّ أدخلني} المدينة {مُدخل صدق} إدخالاً مرضيا لا أرى فيه ما أكره {وأخرجني} من مكة {مُخرج صدق} إخراجا لا ألتفت بقلبي إليها {واجعل لي من لدنك سلطانا نصيرا} قوة تنصرني بها على أعدائك.

See similar narrations below:

Collected by Tirmidhī, Aḥmad, Ḥākim, Bayhaqī
tirmidhi:3139Aḥmad b. Manīʿ > Jarīr > Qābūs b. Abū Ẓabyān from his father > Ibn ʿAbbās

"The Prophet ﷺ was in Makkah, then Hijrah was ordered, so the following was revealed to him: Say: 'My Lord! Let my entry be good, and likewise my exit be good. And grant me from You a helping authority (17:80).'"  

Abū ʿĪsá said that this Ḥadīth is Ḥasan-Ṣaḥīḥ.
الترمذي:٣١٣٩حَدَّثَنَا أَحْمَدُ بْنُ مَنِيعٍ حَدَّثَنَا جَرِيرٌ عَنْ قَابُوسِ بْنِ أَبِي ظَبْيَانَ عَنْ أَبِيهِ عَنِ ابْنِ عَبَّاسٍ قَالَ

كَانَ النَّبِيُّ ﷺ بِمَكَّةَ ثُمَّ أُمِرَ بِالْهِجْرَةِ فَنَزَلَتْ عَلَيْهِ ( قُلْ رَبِّ أَدْخِلْنِي مُدْخَلَ صِدْقٍ وَأَخْرِجْنِي مُخْرَجَ صِدْقٍ وَاجْعَلْ لِي مِنْ لَدُنْكَ سُلْطَانًا نَصِيرًا )  

قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ صَحِيحٌ
ahmad:1948Jarīr > Qābūs from his father

"The Prophet ﷺ was in Makkah, then Hijrah was ordered, so the following was revealed to him: Say: 'My Lord! Let my entry be good, and likewise my exit be good. And grant me from You a helping authority (17:80).'" (Using translation from Tirmidhī 3139)   

أحمد:١٩٤٨حَدَّثَنَا جَرِيرٌ عَنْ قَابُوسَ عَنْ أَبِيهِ

عَنِ ابْنِ عَبَّاسٍ كَانَ رَسُولُ اللهِ ﷺ بِمَكَّةَ ثُمَّ أُمِرَ بِالْهِجْرَةِ وَأُنْزِلَ عَلَيْهِ {وَقُلْ رَبِّ أَدْخِلْنِي مُدْخَلَ صِدْقٍ وَأَخْرِجْنِي مُخْرَجَ صِدْقٍ وَاجْعَلْ لِي مِنْ لَدُنْكَ سُلْطَانًا نَصِيرًا} [الإسراء 80]  

hakim:4259ʿAbdullāh b. Muḥammad b. Mūsá > Ismāʿīl b. Qutaybah > ʿUthmān b. Abū Shaybah > Jarīr > Qābūs b. Abū Ẓabyān from his father > Ibn ʿAbbās

"The Prophet ﷺ was in Makkah, then Hijrah was ordered, so the following was revealed to him: Say: 'My Lord! Let my entry be good, and likewise my exit be good. And grant me from You a helping authority (17:80).'" (Using translation from Tirmidhī 3139)   

الحاكم:٤٢٥٩أَخْبَرَنَا عَبْدُ اللَّهِ بْنُ مُحَمَّدِ بْنِ مُوسَى ثنا إِسْمَاعِيلُ بْنُ قُتَيْبَةَ ثنا عُثْمَانُ بْنُ أَبِي شَيْبَةَ ثنا جَرِيرٌ عَنْ قَابُوسِ بْنِ أَبِي ظَبْيَانَ عَنْ أَبِيهِ عَنِ ابْنِ عَبَّاسٍ قَالَ

كَانَ رَسُولُ اللَّهِ ﷺ بِمَكَّةَ فَأُمِرَ بِالْهِجْرَةِ وَأُنْزِلَ عَلَيْهِ {وَقُلْ رَبِّ أَدْخِلْنِي مُدْخَلَ صِدْقٍ وَأَخْرِجْنِي مُخْرَجَ صِدْقٍ وَاجْعَلْ لِي مِنْ لَدُنْكَ سُلْطَانًا نَصِيرًا} [الإسراء 80]  

«هَذَا حَدِيثٌ صَحِيحُ الْإِسْنَادِ وَلَمْ يُخَرِّجَاهُ» صحيح
bayhaqi:17736Abū ʿAbdullāh al-Ḥāfiẓ > ʿAbdullāh b. Muḥammad b. Mūsá > Ismāʿīl b. Qutaybah > ʿUthmān b. Abū Shaybah > Jarīr > Qābūs b. Abū Ẓabyān > Ibn ʿAbbās

"The Prophet ﷺ was in Makkah, then Hijrah was ordered, so the following was revealed to him: Say: 'My Lord! Let my entry be good, and likewise my exit be good. And grant me from You a helping authority (17:80).'" (Using translation from Tirmidhī 3139)   

البيهقي:١٧٧٣٦حَدَّثَنَا أَبُو عَبْدِ اللهِ الْحَافِظُ أَخْبَرَنِي عَبْدُ اللهِ بْنُ مُحَمَّدِ بْنِ مُوسَى ثنا إِسْمَاعِيلُ بْنُ قُتَيْبَةَ ثنا عُثْمَانُ بْنُ أَبِي شَيْبَةَ ثنا جَرِيرٌ عَنْ قَابُوسَ بْنِ أَبِي ظَبْيَانَ عَنِ ابْنِ عَبَّاسٍ ؓ قَالَ

كَانَ رَسُولُ اللهِ ﷺ بِمَكَّةَ فَأُمِرَ بِالْهِجْرَةِ وَأُنْزِلَ عَلَيْهِ {وَقُلْ رَبِّ أَدْخِلْنِي مُدْخَلَ صِدْقٍ وَأَخْرِجْنِي مُخْرَجَ صِدْقٍ وَاجْعَلْ لِي مِنْ لَدُنْكَ سُلْطَانًا نَصِيرًا} [الإسراء 80]