Skip to the content
Independent guide. Not the Ministry of Hajj and Umrah, and not any government body. Official sites →
Madinah

The history of Madinah

Before Islam, Madinah was Yathrib, an oasis of palm groves and scattered fortified settlements. In 622 it welcomed the Prophet and the Muslims of Makkah, and within ten years it had become the capital of a new community that would spread across Arabia and beyond.

Yathrib before Islam

Yathrib was a farming oasis rather than a trading town like Makkah. Its main Arab tribes, the Aws and the Khazraj, lived alongside several Jewish tribes, including the Banu Qaynuqa, Banu al-Nadir and Banu Qurayzah. Years of feuding between the Aws and the Khazraj had left the oasis divided and in need of a trusted arbiter.

During the pilgrimage seasons of 621 and 622, men from Yathrib met the Prophet at al-Aqabah near Mina, accepted Islam and pledged to protect him. Over the following months most of the Muslims of Makkah quietly moved north.

The Hijrah and a new community

In 622 the Prophet himself left Makkah with Abu Bakr. After hiding in the Cave of Thawr and travelling by a little-used route, they reached Quba on the edge of the oasis, where the first mosque was founded, and then entered the town. The migration, the Hijrah, became year one of the Islamic calendar, and Yathrib became known as Madinat al-Nabi, the city of the Prophet, or simply al-Madinah. The Quba Mosque page tells the story of that first stop.

The Prophet built his mosque, the Prophet's Mosque, with his house beside it. He paired each emigrant from Makkah, the Muhajirun, with a helper from Madinah, the Ansar, who shared homes and livelihoods with them. A written agreement, often called the Constitution of Madinah, set out the rights and duties of the town's Muslim, Jewish and other groups as one community. In 624 the direction of prayer was changed from Jerusalem to the Kaaba in Makkah, an event remembered at the Qiblatayn Mosque.

Badr, Uhud and the Trench

In Ramadan of 624 a small Muslim force of around three hundred met a much larger army of Quraysh at the wells of Badr, south-west of Madinah, and won a decisive victory. A year later, in 625, Quraysh returned and the armies met beneath Mount Uhud, just north of the city. The battle turned against the Muslims after archers left their post on a small hill, and some seventy Muslims were killed, among them the Prophet's uncle Hamzah. Their graves at the foot of Uhud are visited by pilgrims today.

In 627 a coalition of Quraysh and allied tribes, reported at between 7,500 and 10,000 men, marched on Madinah. On the advice of Salman al-Farisi, the Muslims dug a trench across the open northern approach to the city. The besiegers could not cross it, and after about two weeks of cold, wind and failing alliances they withdrew. This was the Battle of the Trench, or of the Confederates, after which Quraysh never again attacked Madinah.

The final years

In 628 the Treaty of Hudaybiyyah brought a truce with Makkah, and in 630 the Prophet returned to Makkah in peace, as told in the history of Makkah. He went back to live in Madinah, received delegations from across Arabia, and in 632 led the Farewell Pilgrimage. A few months later he died in Madinah, in the room of his wife Aisha, and was buried there, beneath what is now the Green Dome.

The city after the Prophet

Madinah was the capital of the first three caliphs, Abu Bakr, Umar and Uthman, and the base from which the early conquests were directed. When Ali moved his capital to Kufa in 656, and the Umayyads later ruled from Damascus, the city's political role declined, but it remained a centre of learning; the jurist Malik ibn Anas, founder of the Maliki school, taught there in the eighth century.

For centuries Madinah was governed by local rulers under the Abbasids, the Mamluks and, from 1517, the Ottomans, who rebuilt much of the Prophet's Mosque. In 1908 the Hejaz Railway from Damascus reached the city. During the First World War an Ottoman garrison held Madinah under siege until early 1919, and in 1925 the city came under the rule of Abdulaziz ibn Saud. Today it is a modern city of around 1.5 million people (2022), still centred on the mosque. For visiting today, start with our Madinah city guide.

Sources

Page updated 2026-11-21