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. Their motivation for this move, apart from recognizing him as the Prophet, the trustworthy, and the best in conduct in Mecca, was to bring peace and security between the Khazraj and Aws. They were often at war with each other and the Battle of Bu'ath had shattered their strength completely. They desperately needed a leader who could be trusted by both communities and bring peace in Medina. As part of the pledge, they were to protect the Prophet as they would protect their women and children if he were attacked by the Meccans.
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).
“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.
“No Believer shall oppose the client of another Believer. Whosoever is rebellious, or seeks to spread injustice, enmity or sedition among the Believers, the hand of every man shall be against him, even if he be a son of one of them. A Believer shall not kill a Believer in retaliation of an unbeliever, nor shall he help an unbeliever against a Believer.
“Whosoever among the Jews follows us shall have help and equality; they shall not be injured nor shall any enemy be aided against them.... No separate peace will be made when the Believers are fighting in the way of Allah.... The Believers shall avenge the blood of one another shed in the way of Allah ....Whosoever kills a Believer wrongfully shall be liable to retaliation; all the Believers shall be against him as one man and they are bound to take action against him.
“The Jews shall contribute (to the cost of war) with the Believers so long as they are at war with a common enemy. The Jews of Banu Najjar, Banu al-Harith, Banu Sa'idah, Banu Jusham, Banu al-Aws, Banu Tha'labah, Jafnah, and Banu al-Shutaybah enjoy the same rights and priviledges as the Jews of Banu Aws.
“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.
Whatever difference or dispute between the parties to this covenant remains unsolved shall be referred to Allah and to Muhammad, the Messenger of Allah. Allah is the Guarantor of the piety and goodness that is embodied in this covenant. Neither the Quraysh nor their allies shall be given any protection.
“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 agianst 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 commited a crime.... Allah is the protector of the good and God-fearing people.”
The first written constitution of a State ever promulgated by a sovereign in human history emanated from the Prophet of Islam. 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.