It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him), Sayyiduna Abu Bakr (may Allah be pleased with him), Sayyiduna Umar (may Allah be pleased with him) and the other Companions of the Messenger of Allah (peace and blessings be upon him) (may Allah be pleased with them) were called Muhajirun, because they had left the polytheists. Some people of the Ansar were also Muhajirun, because Madinah was a town where people (came from outside and) settled; so they came to the Messenger of Allah (peace and blessings be upon him) on the night of al-Aqabah.
Imam al-Nasa'i (may Allah have mercy on him) narrated it in the same way.
Related hadith on this topic