Prophet Muhammad (pbuh) decided to leave Mecca because the Meccan chiefs had taken action to kill him at his home. It was the year 622 CE. As far the choice of migrating to Medina (known as Yathrib at that time), the decision was made easier by the second ‘Pledge of Aqaba’ made a year before on the occasion of the annual rites of pilgrimage. The pledge was made by seventy three men and two women of Khazraj and Aws communities of Medina. They had accepted Islam and wanted to invite the Prophet to migrate to Medina.
Among the people in Medina, there was a small community (three tribes) of Jews with Arab communities constituting the majority of the population. The Jews were traders and many of them used to lend money at exorbitant interest. Their colonies were walled like fortress.
The immediate result of the Prophet’s migration to Medina was peace and unity between the communities of Aws and Khazraj. The Prophet, motivated by the general welfare of citizens of Medina, decided to offer his services to the remaining communities including the Jews. He had already laid down the basis for relationship between the Emigrants from Mecca (known as Muhajirin) and Medinites (known as the Ansar, the helpers).

The Treaty between Muslims, non-Muslim Arabs and Jews of Medina was put in writing and ratified by all parties. It has been preserved by the historians. The major parts of the document were:

“In the name of Allah (The One True God) the Compassionate, the Merciful. This is a document from Muhammad, the Prophet, governing the relation between the Believers from among the Qurayshites (i.e., Emigrants from Mecca) and Yathribites (i.e., the residents of Medina) and those who followed them and joined them and strived with them. They form one and the same community as against the rest of men.

The Jews shall maintain their own religion and the Muslims theirs. Loyalty is a protection against treachery. The close friends of Jews are as themselves. None of them shall go out on a military expedition except with the permission of Muhammad, but he shall not be prevented from taking revenge for a wound.

The Jews shall be responsible for their expenses and the Believers for theirs. Each, if attacked, shall come to the assistance of the other.

“The valley of Yathrib (Medina) shall be sacred and inviolable for all that join this Treaty. Strangers, under protection, shall be treated on the same ground as their protectors; but no stranger shall be taken under protection except with consent of his tribe....No woman shall be taken under protection without the consent of her family.

“The contracting parties are bound to help one another against any attack on Yathrib. If they are called to cease hostilities and to enter into peace, they shall be bound to do so in the interest of peace; and if they make a similar demand on Muslims it must be carried out except when the war is against their religion.

“Allah approves the truth and goodwill of this covenant. This treaty shall not protect the unjust or the criminal. Whoever goes out to fight as well as whoever stays at home shall be safe and secure in this city unless he has perpetrated an injustice or committed a crime.... Allah is the protector of the good and God-fearing people.”
It was enacted from the first year of Hijrah (622 CE). The treaty stipulated a city state in Medina, allowing wide autonomy to communities. Private justice was to be banished. The head of the State had the prerogative to decide who should participate in an expedition, the war and peace being indivisible. Social insurance was to be instituted.

History does not record much as to when first Jewish migration from north to Yathrib (Medina) began as their numbers remained small throughout their stay there. Among the major reasons for their settlements in Arabia were: the relative peace and security in north Arabia with orchards and gardens; the Arab trade route linking Yemen, Arabia, Syria and Iraq; and continuing tensions resulting from wars between the Romans and Persians in the area around the Holy Land. Some of the learned men among the Christians and Jews had also moved to this area based on their conviction that the advent of the final Prophet of God was near, who was to settle in this area. Yathrib was the only city fitting to their description.