What is the the era of medina?
When the tortures of the pagans became unbearable, the Messenger of Allah (blessings and peace be upon him) told his Companions to secretly migrate. The pagans, who learned of this, planned the assassination of our master the Prophet who was left alone. One youth from each tribe was selected and they would all pounce and attack him at the same time. Thus, when the relatives of the Messenger of Allah (blessings and peace be upon him) would ask for indemnity later, they would have to face all the tribes. At that time, God Almighty ordered our master the Prophet to migrate. The Messenger of Allah called HE Ali (Allah be pleased with him) and left him as his agent to deliver the things entrusted with him to their owners. As already mentioned, anyone who possessed valuable property would entrust it to the Messenger of Allah because they knew his loyalty and trustworthiness.
That night the pagan party of assassins surrounded the house but they fell asleep. HE Prophet (blessings and peace be upon him) sprinkled a handful of dust on them and gently passed through them reading the first noble verses of the Chapter Yasin from the Quran. None of them was able to see him.
Thus the Messenger of Allah (blessings and peace be upon him) migrated to Medina after a 13-year struggle to guide people to the right path. He made the Muslims of Medina, the Ansar, brothers with the immigrants from Mecca, the Muhajirin. The Ansar opened their doors to their Muhajirin brothers, saying “Here is my property, half of it is yours!” In response the Muhajirin whose hearts were transformed into a treasury of contentment were able to display the maturity of saying: “May your materials and property be blessed, O my brother! It suffices if you just showed me the way to the market.”
The Messenger of Allah (blessings and peace be upon him) prepared a constitution that determined mutual duties and responsibilities in the new Islamic state of the Muhajirin, Ansar, and Jews who lived in those days in Medina. This was the first written constitution in the history of the world.
The battles of early Islamic history took place because some pagans showed open animosity to Muslims and they frequently breached the agreements that they made with our master the Prophet. The Messenger of Allah (blessings and peace be upon him), who was sent as a mercy to all the worlds, followed such a policy in all these military operations that, even though he eventually conquered the entire Arabian peninsula, he did not allow bloodshed to run amok from either party. He preferred to take care of all the problems through agreements first.
Our master the Prophet personally joined 29 military expeditions. In 16 of them there was no physical conflict and agreements were made with the other party. In thirteen expeditions, he had to engage in physical combat. A total of 140 Muslims became martyrs and about 335 people from the other party died.
The principal purpose of war in Islam is not to kill people, obtain spoils of war, damage the earth, obtain personal benefits and material gains or take revenge. Rather, the purpose is to remove oppression, establish freedom of belief, lead people to the straight path, and remove all kinds of injustices.
 Ibn-i Hishâm, II, 95, 98.
 Bukhari, Büyû, 1.
 M. Hamîdullah, The First Written Constitution in the World, Lahore 1975.
 See Prof. Dr. M. Hamîdullah, Hz. Peygamber’in Savaşları (The Battles of HE the Prophet), Istanbul 1991; Dr. Elşad Mahmudov, Sebep ve Sonuçları Itibâriyle Hazret-i Peygamber’in Savaşları (The Battles of HE Prophet in terms of their Reasons and Results , 2005, M.Ü.S.B.E. Basılmamış Doktora Tezi (Marmara University, Unpublished Doctoral Dissertation).
Source: Dr. Murat Kaya,The Final Divine Religion: ISLAM