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 fooled the Meccans who were watching him, 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.
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 alliance or federation" 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 also adopted some features of the Jewish worship and customs such as fasting on the Yom Kippur day. According to Alford Welch, the Jewish practice of having three daily prayer rituals appears to have been a factor in the introduction of the Islamic midday prayer (previously Muhammad was keeping the morning and evening prayers). Welch thinks that 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.
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.
In the course of Muhammad proselytizing in Mecca, he viewed Christians and Jews (both of whom he referred to as "People of the Book") as natural allies, part of the Abrahamic religions, sharing the core principles of his teachings, and anticipated their acceptance and support. Muslims, like Jews, were at that time praying towards Jerusalem. In the Constitution of Medina, Muhammad demanded the Jews' political loyalty in return for religious and cultural autonomy.
The Jewish clans however kept aloof from Islam though in the course of time there were a few converts from them. After his migration to Medina, Muhammad's attitude towards Christians and Jews changed. Norman Stillman states:
During this fateful time, fraught with tension after the Hijra [migration to Medina], when Muhammad encountered contradiction, ridicule and rejection from the Jewish scholars in Medina, he came to adopt a radically more negative view of the people of the Book who had received earlier scriptures. This attitude was already evolving in the third Meccan period as the Prophet became more aware of the antipathy between Jews and Christians and the disagreements and strife amongst members of the same religion. The Qur'an at this time states that it will "relate [correctly] to the Children of Israel most of that about which they differ" (XXVII, 76).
Economically uprooted by their Meccan persecutors and with no available profession, the Muslim migrants turned to raiding Meccan caravans to respond to their persecution and to provide sustenance for their Muslim families, thus initiating armed conflict between the Muslims and the pagan Quraysh of Mecca. Muhammad delivered Qur'anic verses permitting the Muslims, "those who have been expelled from their homes", to fight the Meccans in opposition to persecution (see Qur'an Sura 22 (Al-Hajj) Ayat 39-40). These attacks provoked and pressured Mecca by interfering with trade, and allowed the Muslims to acquire wealth, power and prestige while working toward their ultimate goal of inducing Mecca's submission to the new faith.
In March 624, Muhammad led some three hundred warriors in a raid on a Meccan merchant caravan. The Muslims set an ambush for the Meccans at Badr. Aware of the plan, the Meccan caravan eluded the Muslims. Meanwhile, a force from Mecca was sent to protect the caravan. The force did not return home upon hearing that the caravan was safe. The battle of Badr began in March 624. Though outnumbered more than three to one, the Muslims won the battle, killing at least forty-five Meccans and taking seventy prisoners for ransom; only fourteen Muslims died. They had also succeeded in killing many of the Meccan leaders, including Abu Jahl. Muhammad himself did not fight, directing the battle from a nearby hut alongside Abu Bakr. In the weeks following the battle, Meccans visited Medina in order to ransom captives from Badr. Many of these had belonged to wealthy families, and were likely ransomed for a considerable sum. Those captives who were not sufficiently influential or wealthy were usually freed without ransom. Muhammad's decision was that those prisoners who refused to end their persecution of Muslims and were wealthy but did not ransom themselves should be killed. Muhammad ordered the immediate execution of two Quraysh men without entertaining offers for their release. Both men, which included Uqba ibn Abu Mu'ayt, had personally attempted to kill Muhammad in Mecca. The raiders had won a lot of treasure, and the battle helped to stabilize the Medinan community. Muhammad and his followers saw in the victory a confirmation of their faith and a prime importance in the affairs of Medina. Those remaining pagans in Medina were very bitter about the advance of Islam. In particular Asma bint Marwan and Abu 'Afak had composed verses insulting some of the Muslims and thereby violated the Constitution of Medina to which they belonged. These two were assassinated and Muhammad did not disapprove of it. No one dared to take vengeance on them, and some of the members of the clan of Asma bint Marwan who had previously converted to Islam in secret, now professed openly. This marked an end to the overt opposition to Muhammad among the pagans in Medina.
Muhammad expelled from Medina the Banu Qaynuqa, one of the three main Jewish tribes. Jewish opposition "may well have been for political as well as religious reasons". On religious grounds, the Jews were skeptical of the possibility of a non-Jewish prophet, and also had concerns about possible incompatibilities between the Qur'an and their own scriptures. The Qur'an's response regarding the possibility of a non-Jew being a prophet was that Abraham was not a Jew. The Qur'an also stated that it was "restoring the pure monotheism of Abraham which had been corrupted in various, clearly specified, ways by Jews and Christians". According to Francis Edwards Peters, "The Jews also began secretly to connive with Muhammad's enemies in Mecca to overthrow him."
Following the battle of Badr, Muhammad also made mutual-aid alliances with a number of Bedouin tribes to protect his community from attacks from the northern part of Hejaz.
The attack at Badr committed Muhammad to total war with Meccans, who were now eager to avenge their defeat. To maintain their economic prosperity, the Meccans needed to restore their prestige, which had been lost at Badr. The Meccans sent out a small party for a raid on Medina to restore confidence and reconnoitre. The party retreated immediately after a surprise and speedy attack but with minor damages; there was no combat. In the ensuing months, Muhammad led expeditions on tribes allied with Mecca and sent out a raid on a Meccan caravan. Abu Sufyan ibn Harb subsequently gathered an army of three thousand men and set out for an attack on Medina. They were accompanied by some prominent women of Mecca, such as Hind bint Utbah, Abu Sufyan's wife, who had lost family members at Badr. These women provided encouragement in keeping with Bedouin custom, calling out the names of the dead at Badr.
A scout alerted Muhammad of the Meccan army's presence and numbers a day later. The next morning, at the Muslim conference of war, there was dispute over how best to repel the Meccans. Muhammad and many of the senior figures suggested that it would be safer to fight within Medina and take advantage of its heavily fortified strongholds. Younger Muslims argued that the Meccans were destroying their crops, and that huddling in the strongholds would destroy Muslim prestige. Muhammad eventually conceded to the wishes of the latter, and readied the Muslim force for battle. Thus, Muhammad led his force outside to the mountain of Uhud (where the Meccans had camped) and fought the Battle of Uhud on March 23.
Although the Muslim army had the best of the early encounters, indiscipline on the part of tactically placed archers led to a tactical defeat for the Muslim army, with 75 Muslims killed. However, the Meccans failed to achieve their goal of destroying the Muslims completely. The Meccans did not occupy the town and withdrew to Mecca, since they were unable to attack Muhammad's position again, owing to military losses, low morale and the possibility of Muslim resistance in the town. There was also hope that Abd-Allah ibn Ubayy leading a group of Muslims in Medina could be won over by diplomacy. Following the defeat, Muhammad's detractors in Medina said that if the victory at Badr was proof of the genuineness of his mission, then the defeat at Uhud was proof that his mission was not genuine. Muhammad subsequently delivered Qur'anic verses 133-135 and 160-162 from the Al-i-Imran sura indicating that the loss, however, was partly a punishment for disobedience and partly a test for steadfastness.
In the battle of Uhud, the Meccans had collected all the available men from the Quraysh and the neighboring tribes friendly to them but had not succeeded in destroying the Muslim community. In order to raise a more powerful army, Abu Sufyan attracted the support of the great nomadic tribes to the north and east of Medina, using propaganda about Muhammad's weakness, promises of treasure, memories of the prestige of Quraysh and straight bribes.
Muhammad's policy in the next two years after the battle of Uhud was to prevent as best he could the formation of alliances against him. Whenever alliances of tribesmen against Medina were formed, he sent out an expedition to break it up. When Muhammad heard of men massing with hostile intentions against Medina, he reacted with severity. One example is the assassination of Ka'b ibn al-Ashraf, a member of the Jewish tribe of Banu Nadir who had gone to Mecca and written poems that had helped rouse the Meccans' grief, anger and desire for revenge after the battle of Badr (see the main article for other reasons for killing of Ka'b given in the historiographical sources). Around a year later, Muhammad expelled the Jewish Banu Nadir from Medina.
Muhammad's attempts to prevent formation of confederation against him were not successful, although he was able to augment his own forces and keep many tribes from joining the confederation.
Abu Sufyan, the military leader of the Quraysh, with the help of Banu Nadir, the exiled Jewish tribe from Medina, had mustered a force of numbering 10,000 men. Muhammad was able to prepare a force of about 3,000 men. He had however adopted a new form of defense, unknown in Arabia at that time: Muslims had dug trenches wherever Medina lay open to cavalry attack. The idea is credited to a Persian convert to Islam, Salman. The siege of Medina began on 31 March 627 and lasted for two weeks. Abu Sufyan's troops were unprepared for the fortifications they were confronted with, and after an ineffectual siege, the coalition decided to go home. The Qur'an discusses this battle in verses 9-27 of sura 33, Al-Ahzab.
During the Battle of the Trench, the Jewish tribe of Banu Qurayza who were located at the south of Medina were charged with treachery. After the retreat of the coalition, Muslims besieged Banu Qurayza, the remaining major Jewish tribe in Medina. The Banu Qurayza surrendered and all the men, apart from a few who converted to Islam, were beheaded, while all the women and children were enslaved. In dealing with Muhammad's treatment of the Jews of Medina, aside from political explanations, Arab historians and biographers have explained it as "the punishment of the Medina Jews, who were invited to convert and refused, perfectly exemplify the Quran's tales of what happened to those who rejected the prophets of old." F.E. Peters, a western scholar of Islam, states that Muhammad's treatment of Jews of Medina was essentially political being prompted by what Muhammad read as treasonous and not some transgression of the law of God. Peters adds that Muhammad was possibly emboldened by his military successes and also wanted to push his advantage. Economical motivations according to Peters also existed since the poorness of the Meccan migrants was a source of concern for Muhammad. Peters argues that Muhammad's treatment of the Jews of Medina was "quite extraordinary", "matched by nothing in the Qur'an", and is "quite at odds with Muhammad's treatment of the Jews he encountered outside Medina." According to Welch, Muhammad's treatment of the three major Jewish tribes brought Muhammad closer to his goal of organizing a community strictly on a religious basis. He adds that some Jews from other families were, however, allowed to remain in Medina.
In the siege of Medina, the Meccans had exerted their utmost strength towards the destruction of the Muslim community. Their failure resulted in a significant loss of prestige; their trade with Syria was gone. Following the battle of trench, Muhammad made two expeditions to the north which ended without any fighting. While returning from one of these two expeditions (or some years earlier according to other early accounts), an accusation of adultery was made against Aisha, Muhammad's wife. Aisha was exonerated from the accusations when Muhammad announced that he had received a revelation, verse4 in the An-Nur sura, confirming Aisha's innocence and directing that charges of adultery be supported by four eyewitnesses.
Although Qur'anic verses had been received from God commanding the Hajj, the Muslims had not performed it due to the enmity of the Quraysh. In the month of Shawwal 628, Muhammad ordered his followers to obtain sacrificial animals and to make preparations for a pilgrimage (umrah) to Mecca, saying that God had promised him the fulfillment of this goal in a vision where he was shaving his head after the completion of the Hajj. According to Lewis, Muhammad felt strong enough to attempt an attack on Mecca, but on the way it became clear that the attempt was premature and the expedition was converted into a peaceful pilgrimage. Andrae disagrees, writing that the Muslim state of ihram (which restricted their freedom of action) and the paucity of arms carried indicated that the pilgrimage was always intended to be pacific. Upon hearing of the approaching 1,400 Muslims, the Quraysh sent out a force of 200 cavalry to halt them. Muhammad evaded them by taking a more difficult route, thereby reaching al-Hudaybiyya, just outside Mecca. According to Watt, although Muhammad's decision to make the pilgrimage was based on his dream, he was at the same time demonstrating to the pagan Meccans that Islam does not threaten the prestige of their sanctuary, and that Islam was an Arabian religion.
Negotiations commenced with emissaries going to and from Mecca. While these continued, rumors spread that one of the Muslim negotiators, Uthman ibn Affan, had been killed by the Quraysh. Muhammad responded by calling upon the pilgrims to make a pledge not to flee (or to stick with Muhammad, whatever decision he made) if the situation descended into war with Mecca. This pledge became known as the "Pledge of Good Pleasure" (Arabic: بيعة الرضوان , bay'at al-ridhwān) or the "Pledge of the Tree." News of Uthman's safety, however, allowed for negotiations to continue, and the treaty of Hudaybiyyah, scheduled to last ten years was eventually signed between the Muslims and the Quraysh. The main points of treaty were the following:
- The two parties and their allies should desist from hostilities against each other.
- Muhammad, should not perform Hajj this year but in the next year, Mecca will be evacuated for three days for Muslims to perform Hajj.
- Muhammad should send back any Meccan who had gone to Medina without the permission of his or her protector (according to William Montgomery Watt, this presumably refers to minors or women).
- It was allowed for both Muhammad and the Quraysh to enter into alliance with others.
Many Muslims were not satisfied with the terms of the treaty. However, the Qur'anic sura Al-Fath (The Victory) assured the Muslims that the expedition from which they were now returning must be considered a victorious one. It was only later that Muhammad's followers would realise the benefit behind this treaty. These benefits, according to Welch, included the inducing of the Meccans to recognise Muhammad as an equal; a cessation of military activity posing well for the future; and gaining the admiration of Meccans who were impressed by the incorporation of the pilgrimage rituals.
After signing the truce, Muhammad made an expedition against the Jewish oasis of Khaybar. The explanation given by western scholars of Islam for this attack ranges from the presence of the Banu Nadir in Khaybar, who were inciting hostilities along with neighboring Arab tribes against Muhammad, to deflecting from what appeared to some Muslims as the inconclusive result of the truce of Hudaybiyya, increasing Muhammad's prestige among his followers and capturing booty. According to Muslim tradition, Muhammad also sent letters to many rulers of the world, asking them to convert to Islam (the exact date are given variously in the sources). Hence he sent messengers (with letters) to Heraclius of the Byzantine Empire (the eastern Roman Empire), Khosrau of Persia, the chief of Yemen and to some others. Most critical scholars doubt this tradition, however. In the years following the truce of Hudaybiyya, Muhammad sent his forces against the Arabs of Mu'tah on Byzantine soil in Transjordania since according to the tradition, they had murdered Muhammad's envoy. F. Buhl however holds that the real reason "seems to have been that he wished to bring the (Christian or pagan) Arabs living there under his control." Muslims were defeated in this battle.
The truce of Hudaybiyya had been enforced for two years. The tribe of Khuz'aah had a friendly relationship with Muhammad, while on the other hand their enemies, the Banu Bakr, had an alliance with the Meccans. A clan of the Bakr made a night raid against the Khuz'aah, killing a few of them. The Meccans helped their allies (i.e., the Banu Bakr) with weapons and, according to some sources, a few Meccans also took part in the fighting. After this event, Muhammad sent a message to Mecca with three conditions, asking them to accept one of them. These were the following
- The Meccans were to pay blood money for those slain among the Khuza'ah tribe, or
- They should have nothing to do with the Banu Bakr, or
- They should declare the truce of Hudaybiyya null.
The Meccans replied that they would accept only the third condition. However, soon they realized their mistake and sent Abu Safyan to renew the Hudaybiyya treaty, but now his request was declined by Muhammad. Muhammad began to prepare for a campaign.
In 630, Muhammad marched on Mecca with an enormous force, said to number more than ten thousand men. With minimal casualties, Muhammad took control of Mecca. He declared an amnesty for past offences, except for ten men and women who had mocked and made fun of him in songs and verses. Some of these were later pardoned. Most Meccans converted to Islam, and Muhammad subsequently destroyed all of the statues of Arabian gods in and around the Kaaba, without any exception. The Qur'an discusses the conquest of Mecca in verses 1-3 of the An-Nasrsura.
Soon after the conquest of Mecca, Muhammad was alarmed by a military threat from the confederate tribes of Hawazin who were collecting an army twice the size of Muhammad's. The Hawzain were old enemies of Meccans. They were joined by the tribe of Banu Thaqif inhabiting in the city of Ta’if who had adopted an anti-Meccan policy due to the decline of the prestige of Meccans. Muhammad defeated the Hawzain and Thaqif in the battle of Hunayn.
In the same year, Muhammad launched an expedition against northern Arabia, the battle of Tabouk, because of their previous defeat at the battle of Mu'tah, as well as the reports of the hostile attitude adopted against Muslims. Although Muhammad did not make contact with hostile forces at Tabuk, he received the submission of some of the local chiefs of the region. A year after the battle of Tabuk, the tribe of Thaqif, inhabiting in the city of Ta’if, sent emissaries to Medina to surrender to Muhammad and adopt Islam. Many Bedouins submitted to Muhammad in order to be safe from attack and to benefit from the booty of the wars. The Bedouins however were alien to the system of Islam and wanted to maintain their independence, their established code of virtue and their ancestral traditions. Consequently, Muhammad demanded of them a military and political agreement according to which they "acknowledge the suzerainty of Medina, [promise] to refrain from attacking the Muslims and their allies, and to pay the Zakat, the Muslim religious levy."
At the end of the tenth year after the migration to Medina, Muhammad performed his first truly Islamic pilgrimage, thereby teaching his followers the rules governing the various ceremonies of the annual Great Pilgrimage (hajj). On this occasion, he uttered the Qur'anic verse:
This day have I perfected your religion for you, completed My favour upon you, and have chosen for you Islam as your religion.
A few months after the farewell pilgrimage, Muhammad fell ill and suffered for several days with head pain and weakness. He died on Monday, June 8, 632, in the city of Medina. His tomb had previously been the home of his wife Aisha. It is now enclosed within Al-Masjid al-Nabawi (Mosque of the Prophet) in Medina.