In Medina

Hijra
By 622, life in the small Muslim community of Mecca was becoming not only difficult, but dangerous. Muslim traditions say that there were several attempts to assassinate Muhammad. Muhammad then resolved to emigrate to Medina, then known as Yathrib, a large agricultural oasis where there were a number of Muslim converts. By breaking the link with his own tribe, Muhammad demonstrated that tribal and family loyalties were insignificant compared to the bonds of Islam, a revolutionary idea in the tribal society of Arabia. This Hijra or emigration (traditionally translated into English as "flight") marks the beginning of the Islamic calendar. The Muslim calendar counts dates from the Hijra, which is why Muslim dates have the suffix AH (After Hijra).

Muhammad came to Medina as a mediator, invited to resolve the feud between the Arab factions of Aws and Khazraj. He ultimately did so by absorbing both factions into his Muslim community, forbidding bloodshed among Muslims. However, Medina was also home to a number of Jewish tribes (whether they were ethnically as well as religiously Jewish is an open question, as is the depth of their "Jewishness"). Islamic tradition refers to the conversion to Islam of one of the leaders of the Jews named Ibn Salam. Muhammad had hoped that his conversion would be emulated by the other Jews, and that those others would also recognize him as a prophet, but they did not do so.

Some academic historians attribute the change of qibla, the Muslim direction of prayer, from the site of the former Temple in Jerusalem to the Kaaba in Mecca, which occurred during this period, to Muhammad's abandonment of hope of recruiting Jews as allies or followers. According to Muslims, the change of qibla was seen as a command from God both reflecting the independence of the Muslims as well as a test to discern those who truly followed the revelation and those who were simply opportunistic.

Muhammad and his followers are said to have negotiated an agreement with the other Medinans, a document now known as the Constitution of Medina (date debated), which laid out the terms on which the different factions, specifically the Jews and other "Peoples of the Book" could exist within the new Islamic State.
 

War
Relations between Mecca and Medina rapidly worsened (see surat al-Baqara). Meccans confiscated all the property that the Muslims had left in Mecca. In Medina, Muhammad signed treaties of alliance and mutual help with neighboring tribes.

Muhammad turned to raiding caravans bound for Mecca. Caravan-raiding was an old Arabian tradition and according to Watt was "a kind of sport rather than war"[7] and that the object of the raids was to take animals and other goods but killing was carefully avoided. [8]; Muslims justified the raids by the Meccans' confiscation of the property they had left at Mecca and the state of war deemed to exist between the Meccans and the Muslims.

In March of 624, Muhammad led some three hundred warriors in a raid on a Meccan merchant caravan. The Meccans successfully defended the caravan and then decided to teach the Medinans a lesson. They sent a small army against Medina. On March 15, 624 near a place called Badr, the Meccans and the Muslims clashed. Though outnumbered more than three times (one thousand to three hundred) in the battle, the Muslims met with success, killing at least forty-five Meccans and taking seventy prisoners for ransom; only fourteen Muslims died. This marked the real beginning of Muslim military achievement.

 
Rule consolidated
To his followers, the victory in Badr apparently seemed a divine authentication of Muhammad's prophethood. Following this victory, the victors expelled a local Jewish clan, the Banu Qainuqa, whom they accused of having broken a treaty by conspiring with the attacking Meccan forces. Muhammad and his followers were now a dominant force in the oasis of Yathrib (Medina).

After Khadija's death, Muhammad had married Aisha, the daughter of his friend Abu Bakr (who would later emerge as the first leader of the Muslims after Muhammad's death). In Medina, he married Hafsah, daughter of Umar (who would eventually become Abu Bakr's successor).

Muhammad's daughter Fatima married Ali, Muhammad's cousin. According to the Sunni, another daughter, Umm Kulthum, married Uthman. Each of these men, in later years, would emerge as successors to Muhammad and political leaders of the Muslims. Thus, all four caliphs were linked to Muhammad by marriage. Sunni Muslims regard these caliphs as the Rashidun, or Rightly Guided. (See Succession to Muhammad for more information on the controversy on the succession to the caliphate).


Continued warfare
In 625 the Meccan general Abu Sufyan marched on Medina with three thousand men. The ensuing Battle of Uhud took place on March 23 and ended in a stalemate. The Meccans claimed victory, but they had lost too many men to pursue the Muslims into Medina.

In April 627, Abu Sufyan led another strong force against Medina. But Muhammad had dug a trench around Medina and successfully defended the city in the Battle of the Trench.

Many of the Muslims believed that Abu Sufyan had been aided by sympathizers among the Medinans, being the Jewish tribe of Banu Qurayza, with whom the Muslims had a treaty. They attacked and defeated the Banu Qurayza, and subsequently executed hundreds of the adult men of the tribe, after trying them for treason.[citation needed]This execution has been the subject of some controversy.[citation needed]

Following the Muslims' victory at the Battle of the Trench, the Muslims were able, through conversion and conquest, to extend their rule to many of the neighboring cities and tribes.[citation needed]


The truce of Hudaybiyya
Although revelation (2:196-2:210) about the performing of Hajj had already come, Muhammad and Muslims did not do it due to the enmity of the Quraish. It was the month of Shawwal 6 A.H. when Muhammad saw in a vision that he was shaving his head after the Hajj. [9][10] Muhammad therefore decided to perform the Haj in the following month. Hence around the 13th of March, 628 with 1400 Companions he went towards Medina without the least intention of giving a battle.[11] But the Quraish were determined to offer resistance to Muslims and they posted themselves outside Mecca, closing all access to the city. [11]. In order to settle the dispute peacefully Muhammad halted at a placed called Hudaybiyya. Hence after series of talks a treaty was signed. The main points of treaty were the following.
 They have agreed to lay down the burden of war for ten years [12][13]
  Muhammad, should not perform Hajj this year [12] [14]
  They may come next year to perform Haj (unarmed) but shall not stay in Mecca for more than three days [12] [14]
  Any Muslim living in Mecca cannot settle in Medina but Medina Muslim may come and join Meccans (and will not be returned). [15]

Many of Muslims were not satisfied with the terms the treaty is made. However, on the way to Madina, God revealed the Prophet a new chapter of Quran named "Al-Fath" (The victory) 48:1-48:29. The new Revelation left no doubt in Muslims' minds that the expedition from which they were now returning must be considered a victorious one. [16][17]. With the passage of time it become more and more apparent why the Koran had declared the truce a victory. The men of Mecca and Medina could now meet in peace and discuss Islam hence during the following two years the community of Islam was more than doubled.[18] [19] [20]


Muhammad letters to the Heads-of-State

After the truce signed by the Hudaybiyya, Muhammad decided to send letters to many rulers of the world, inviting them to Islam [21] [22][23] Hence he sent messengers (with letters) to Heraclius of the Byzantine Empire (The eastern Roman Empire), Chosroes of Persia, the chief of Yemen and to some others. [21] [22]