The Prophet ﷺ was in Mecca when he was commanded to migrate, and the verse was revealed to him, "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" [Isra 17:80].
حدثنا أحمد بن منيع حدثنا جرير عن قابوس بن أبي ظبيان عن أبيه
كان النبي ﷺ بمكة ثم أمر بالهجرة فنزلت عليه {وقل رب أدخلني مدخل صدق وأخرجني مخرج صدق واجعل لي من لدنك سلطانا نصيرا}
[Its isnad is daif] Ahmad narrated it: 1/223 through Jareer bin Abdul-Hameed with the same wording. Qabus is daif, as mentioned earlier.