Migration gave the young Muslim community a home; the eight years that followed gave it a shape. In Medina the Prophet Muhammad ﷺ governed a growing city, weathered wars he did not seek, and signed a treaty that looked, on its surface, like a defeat. The Quran's commentary on these events consistently points past the fighting itself toward what each moment demanded of belief.
Building a community
The Prophet ﷺ built a mosque of unbaked brick and palm trunks in Medina that served at once as a place of prayer, a courtroom, a guesthouse, and a meeting hall — the center of a community that was also, from its first months, learning to govern itself. Markets were organized, treaties were made with neighboring tribes, and the Constitution of Medina (described in the Hijra) gave the city's different communities a shared framework of rights and obligations.6710 Mecca, however, had not accepted the loss of the Prophet's ﷺ following, and the peace of Medina's early years did not last.
Badr: a small force and a large lesson
In 624 CE, a Meccan caravan and the Muslims' interception of it drew a large Meccan army out to the wells of Badr, where a Muslim force roughly a third its size won a decisive victory. The battle is traditionally remembered as the first major armed confrontation of the Prophet's ﷺ mission and a moment that forced Mecca to reckon with Medina as a serious power.679 The Quran frames the victory not as a matter of numbers or tactics but of divine support granted to a community that had been driven from its home for its faith:
And already had Allah given you victory at Badr while you were few in number. Then fear Allah; perhaps you will be grateful.
— Quran 3:123 (Saheeh International)1
Uhud: the cost of leaving one's post
Mecca returned the following year with a larger force, meeting the Muslims near Mount Uhud in 625 CE. The battle began well for the Muslims, but a company of archers stationed on high ground left their post to join in gathering the spoils of an apparent Meccan retreat, exposing the Muslim flank to a counterattack that turned the battle and wounded the Prophet ﷺ himself.678 Rather than dwell on the tactics of the day, the Quran's extended commentary on Uhud reads as self-examination — addressing the believers' grief, their doubt, and above all the lapse in discipline that had cost them so heavily:
And Allah had certainly fulfilled His promise to you when you were killing the enemy by His permission until [the time] when you lost courage and fell to disputing about the order [given by the Prophet] and disobeyed after He had shown you that which you love... Then He turned you away from them [defeated] that He might test you.
— Quran 3:152 (Saheeh International)2
Uhud has been remembered in the Muslim tradition less as a military loss to avenge than as a lesson in obedience and the danger of prizing worldly gain over a shared task.678
The Trench: a siege that ended without battle
By 627 CE, Mecca had assembled a large confederacy of tribes to overwhelm Medina outright. On the advice of the Persian companion Salman al-Farisi, the Muslims dug a trench along the city's one exposed approach, a defensive method unfamiliar to the besieging Arabian tribes. The siege dragged on for roughly a month before harsh weather and mutual distrust broke the coalition apart, and the confederates withdrew without the pitched battle either side had prepared for.679 The Quran's commentary on the siege dwells on the fear the community felt while surrounded, and on the trial that fear represented:
[Remember] when they came at you from above you and from below you, and when eyes shifted [in fear], and hearts reached the throats, and you assumed about Allah [various] assumptions. There, the believers were tested and shaken with a severe shaking.
— Quran 33:10-11 (Saheeh International)3
Hudaybiyyah: a victory that looked like defeat
In 628 CE, the Prophet ﷺ led over a thousand followers toward Mecca intending to perform pilgrimage, unarmed for war. Quraysh refused them entry, and after tense negotiation the two sides signed the Treaty of Hudaybiyyah: a ten-year truce under which the Muslims would return home that year without completing the pilgrimage, but would be free to come the following year, and in which Quraysh's terms on paper looked, to many of the Prophet's ﷺ own companions, like a concession.6710 The Quran addressed that disappointment directly, opening the chapter revealed soon afterward by naming the treaty something other than what it appeared to be:
Indeed, We have given you, [O Muhammad], a clear conquest.
— Quran 48:1 (Saheeh International)4
The years of calm the truce secured allowed the Muslim message to travel far beyond what the sword had achieved: by the time Quraysh broke the treaty two years later, the Muslim community had grown large enough that the ensuing conquest of Mecca met almost no resistance at all — the very outcome later commentators point to in calling Hudaybiyyah a victory in substance, however it appeared at the time.7810
Letters to rulers
Around this same period, traditional accounts describe the Prophet ﷺ sending letters inviting several regional rulers to Islam, among them the Byzantine emperor Heraclius, the Persian emperor Khosrow II, and the Muqawqis of Egypt — a set of episodes Muslim historians have long read as a sign that the Medinan community now understood itself as a political actor with a message meant for more than Arabia alone.678
Among his people
Away from battles and treaties, the hadith literature preserves a portrait of a leader who remained, by his companions' account, remarkably approachable. Anas ibn Malik, who served the Prophet ﷺ for ten years in Medina, recalled:
I served the Prophet for ten years, and he never said to me, "Uff" (a minor harsh word denoting impatience), and never blamed me by saying, "Why did you do so or why didn't you do so?"
— Sahih al-Bukhari 60385
That combination — a community facing real external threats, led by a man remembered above all for his patience within it — is how the Medinan years are remembered by the tradition: not as a record of wars sought out, but as a community's education in what its faith asked of it under pressure.
Where to go next
The truce at Hudaybiyyah opened the final phase of the Prophet's ﷺ life in Medina, one that ended with Mecca itself opening its gates. That story continues in the conquest of Mecca and farewell.