Explanation
A delegation from Medina, consisting of the representatives of the twelve important clans of Medina, invited Muhammad as a neutral outsider to serve as the chief arbitrator for the entire community. There was fighting in Yathrib (Medina) mainly involving its Arab and Jewish inhabitants for around a hundred years before 620. The recurring slaughters and disagreements over the resulting claims, especially after the battle of Bu'ath in which all the clans were involved, made it obvious to them that the tribal conceptions of blood-feud and an eye for an eye were no longer workable unless there was one man with authority to adjudicate in disputed cases. The delegation from Medina pledged themselves and their fellow-citizens to accept Muhammad into their community and physically protect him as one of themselves.
Muhammad instructed his followers to emigrate to Medina until virtually all of his followers had left Mecca. Being alarmed at the departure of Muslims, according to the tradition, the Meccans plotted to assassinate him. He instructed his cousin and future son-in-law Ali to sleep in his bed to trick the assassins that he had stayed (and to fight them off in his stead) and secretly slipped away from the town. By 622, Muhammad had emigrated to Medina, then known as Yathrib, a large agricultural oasis. Following the emigration, the Meccans seized the properties of the Muslim emigrants in Mecca.
The first group of pagan converts to Islam in Medina were the clans who had not produced great leaders for themselves but had suffered from warlike leaders from other clans. This was followed by the general acceptance of Islam by the pagan population of Medina, apart from some exceptions. This was, according to Ibn Ishaq, influenced by the conversion to Islam of Sa'd ibn Mua'dh, one of the prominent leaders in Medina.Among the things Muhammad did in order to settle the longstanding grievances among the tribes of Medina was drafting a document known as the Constitution of Medina (date debated), establishing a kind of brotherhood among the eight Medinan tribes and Muslim emigrants from Mecca, which specified the rights and duties of all citizens and the relationship of the different communities in Medina (including that of the Muslim community to other communities specifically the Jews and other "Peoples of the Book"). The community defined in the Constitution of Medina, umma, had a religious outlook but was also shaped by the practical considerations and substantially preserved the legal forms of the old Arab tribes. Muhammad's adoption of facing north towards Jerusalem when performing the daily prayers (qibla) however need not to necessarily be a borrowing from the Jews as the reports about the direction of prayer before migration to Medina are contradictory and further this direction of prayer was also practiced among other groups in Arabia.