Battle of the Trench: How a Ditch Saved Madinah (Ghazwat al-Khandaq)

It is the battle that was won without a battle. In Shawwal 5 AH, the largest army Arabia had ever gathered — some ten thousand men of Quraysh, Ghatafan and their confederates — marched on Madinah to finish Islam.

Between them and the city, the Muslims dug something Arabia had never seen: a trench, five and a half kilometres long, on the advice of a Persian Companion.

The confederates stared at it, besieged the city for close to a month, and went home defeated by hunger, cold wind and their own divisions.

This is the Battle of the Trench — Ghazwat al-Khandaq, also called the Battle of the Confederates (Al-Ahzab) — and its ground, at the foot of Mount Sela’, is one of the essential stops of the Madinah ziyarat.

Quick Facts — Battle of the Trench
Date Shawwal 5 AH (627 CE)
Place Northern edge of Madinah, at the foot of Mount Sela’ — today’s Al-Fath / Khandaq district
The armies About 10,000 confederates against about 3,000 Muslims
The trench Commonly cited as about 5.5 km long, 4.5 m deep and 9 m wide — dug in roughly six days
The siege Close to a month, ended by a bitter wind that wrecked the confederate camp (Quran 33:9)
What stands there today The Seven Mosques and the large Masjid al-Khandaq — no trace of the trench itself survives

Why the Confederates Came

By 5 AH the Quraysh had lost at Badr and failed to win at Uhud.

For one final effort they built the largest coalition of the age — the Ahzab, the Confederates: Quraysh under Abu Sufyan, the Ghatafan tribes bought with the promise of Khaybar’s harvest, and smaller allies, some ten thousand fighting men with hundreds of horses. Against them Madinah could field about three thousand.

Open battle against such numbers, on the Uhud model, would have been annihilation. Madinah needed a defence Arabia had never tried — and one man in the city had seen warfare beyond Arabia.

Salman’s Idea: A Trench Across the North

Salman al-Farsi (RA) was a Persian who had crossed the world searching for the truth before he reached the Prophet ﷺ. In Persia, he explained, when a city feared a stronger enemy, it dug a trench.

Madinah was guarded on its other sides by lava fields and palm groves; only the northern approach lay open. So across that approach the Muslims dug — the Prophet ﷺ marking out the line and assigning every group of ten men its stretch.

The commonly cited figures give a trench about 5.5 km long, some 4.5 metres deep and 9 metres wide — too wide for a horse to leap, too deep to scramble out of under arrows — completed in roughly six days of desperate work.

The digging itself became legend. The Companions worked hungry and cold, singing as they dug, and the Prophet ﷺ dug and carried earth with them until his own back was bent under the loads — Sahih al-Bukhari preserves the scene.

When a rock defeated every pick in one section, the Prophet ﷺ struck it himself; the reports describe flashes at each blow, in which he was shown the palaces of Syria, Persia and Yemen — the very empires the confederates thought would swallow Islam, promised instead to the diggers in the ditch.

The entrance and information boards at the Khandaq site in Madinah today
The Khandaq site today — information boards at the entrance tell the story of the siege where the trench line ran. Photo: Wikimedia Commons.

A Month of Siege: The Duel, the Betrayal, the Wind

The confederates arrived, saw the trench, and stopped — “a stratagem Arabs do not know,” their leaders admitted.

What followed was not a battle but an ordeal of close to a month: arrows exchanged across the ditch, the city behind the line going hungry, and fear on every side, which the Quran describes without flinching — “when they came at you from above you and from below you, and when eyes shifted and hearts reached the throats” (Quran 33:10).

A handful of horsemen, led by the champion Amr ibn Abd Wudd, found a narrow place and leapt across; Ali ibn Abi Talib (RA) went out to meet Amr and killed him in single combat, and the others withdrew.

Behind the lines, the tribe of Banu Qurayzah broke its pact with the Prophet ﷺ, opening a second front against the city’s families — the crisis of the siege.

The danger was dissolved in part by Nu’aym ibn Mas’ud (RA), a new Muslim whose identity the confederates did not know, who sowed distrust between Quraysh, Ghatafan and Qurayzah until the alliance began to eat itself.

Then came the last night. A bitter, freezing wind rose and tore through the confederate camp — overturning cooking pots, extinguishing fires, uprooting tents.

The Quran names it among Allah’s favours: “O you who believe, remember the favour of Allah upon you when armies came to you, and We sent upon them a wind and armies you did not see” (Quran 33:9). Abu Sufyan gave the order to withdraw.

By morning the plain was empty, and the Prophet ﷺ said: “Now we shall raid them, and they shall not raid us.” Never again did Makkah march on Madinah. The whole siege is preserved in the surah named after the confederates — Surah Al-Ahzab, chapter 33.

The mosque of Salman al-Farsi at the Seven Mosques on the trench site
The small mosque of Salman al-Farsi (RA) — the Companion whose Persian idea dug the trench — on the slope above the site. Photo: Wikimedia Commons.

What You Can See at the Trench Site Today

Be prepared for an honest disappointment that becomes, with the story in mind, something better: no part of the original trench survives. The city grew over its own battlefield; the line of the ditch lies beneath the modern Al-Fath district at the foot of Mount Sela’.

What marks the ground is the row of the Seven Mosques on the slope — Al-Fath, where the Prophet ﷺ prayed for victory through the siege, and the small mosques of Salman, Abu Bakr, Umar, Ali and Fatimah — with the large modern Masjid al-Khandaq below them for prayer, and information boards at the site entrance telling the story in several languages.

Stand by those boards, look north across the district, and picture the ditch between you and the ten thousand.

The visit pairs naturally with Masjid Qiblatain, a few minutes away, on the western round of our Ziyarat in Madinah guide — and it takes no more than half an hour once you arrive.

Come having read the story; at Khandaq, more than anywhere else in Madinah, the seeing is in the knowing.

Related Guides

Frequently Asked Questions

What was the Battle of the Trench?

The Battle of the Trench (Ghazwat al-Khandaq, 5 AH / 627 CE) was the siege of Madinah by a confederate army of about 10,000.

On Salman al-Farsi’s advice the Muslims dug a trench across the city’s open northern side; the confederates could not cross it, besieged the city for close to a month, and withdrew after a storm wrecked their camp.

Who suggested digging the trench?

Salman al-Farsi (RA), the Persian Companion of the Prophet ﷺ. Trench warfare was a Persian method unknown in Arabia; he proposed it, the Prophet ﷺ approved it, and the whole community — the Prophet ﷺ digging alongside them — completed roughly 5.5 km of trench in about six days.

How long did the siege of the Trench last?

Close to a month — the sources give figures between about twenty nights and a full month. It ended without a pitched battle when a cold windstorm destroyed the confederate camp’s tents and fires, and Abu Sufyan ordered the withdrawal (Quran 33:9).

Can you still see the trench in Madinah?

No. No visible section of the original trench remains — the modern city covers its line. The site, at the foot of Mount Sela’, is marked by the Seven Mosques, the large Masjid al-Khandaq, and information boards that explain the battle on the ground where it happened.

Where was the Battle of the Trench fought?

Across the northern approach to Madinah, in the area at the foot of Mount Sela’ now known as the Al-Fath / Khandaq district, a few kilometres north-west of Masjid al-Nabawi. The Muslim camp stood on Sela’s slope, where the Seven Mosques now mark its positions.

Fahad Al-Harbi

About the Author

Fahad Al-Harbi is the Editor of The Saudi Post. He writes about Makkah and Madinah ziyarat, Umrah travel and everyday life in Saudi Arabia, with a focus on clear, practical guidance for pilgrims and residents.

One thought on “Battle of the Trench: How a Ditch Saved Madinah (Ghazwat al-Khandaq)”

Leave a Reply

Your email address will not be published. Required fields are marked *