"Ibn 'Abbas said: 'The Messenger of Allah ﷺ, Abu Bakr and 'Umar were among the Muhajirin (emigrants), because they forsook (hajaru) the idolators, and some of the Ansar were Muhajirun because Al-Madinah was a land of shirk, and they came to the Messenger of Allah ﷺ on the Night of Al-'Aqabah."' (Using translation from Nasāʾī 4166)
قَالَ ابْنُ عَبَّاسٍ «كَانَ رَسُولُ اللهِ ﷺ بِمَكَّةَ وَإِنَّ أَبَا بَكْرٍ وَعُمَرَ وَأَصْحَابَ النَّبِيِّ ﷺ كَانُوا مِنَ الْمُهَاجِرِينَ لِأَنَّهُمْ هَجَرُوا الْمُشْرِكِينَ وَكَانَ الْأَنْصَارُ مُهَاجِرِينَ لَأَنَّ الْمَدِينَةَ كَانَتْ دَارَ شِرْكٍ فَجَاءُوا إِلَى النَّبِيِّ ﷺ لَيْلَةَ الْعَقَبَةِ»