Muhammad is no more than an apostle: many were the apostle that passed away before him. If he died or was slain, will you then turn back on your heels? If any did turn back on his heels, not the least harm will he do to Allah. But Allah (on the other hand) will swiftly reward those who (serve Him) with gratitude. Holy Qur’an, 3:144

Having faced hostile aggression, economic boycott and expulsion, an invitation was extended to the Prophet and his followers to uproot themselves from their homeland and migrate to the desert oasis of Yathrib (which was later renamed Madinah). The invitation came from the Ansar (Helpers) who were the inhabitants of Madinah.[1] In the year 622 CE, the Prophet and the Muhajireen[2] arrived in Madinah and along with the Ansar, they established the first official Muslim state.

[1] The Ansar (the Helpers) consisted of two tribes, the Aws and the Khazraj who lived in the oasis desert of Yathrib which is about 250 miles northeast of Mecca. These two tribes had been at bitter and deadly odds with each other for many years and with the Prophet’s assistance, they put aside their differences and invited the Prophet and his followers to Yathrib, which was later renamed Madinah.
[2] Those who migrated with the Prophet from Mecca to Madinah are known as the Muhajireen – a term that means someone who is fleeing. The Muhajireen were the indigenous inhabitants of Mecca, mainly from the tribe of Quraysh.

When Power and Piety Collide by Sayed Moustafa al-Qazwini