The Trench is located between the volcanic areas of Waqim and Al-Wabra. Here, the Muslims dug a trench to protect Madinah when the Quraysh and their allied tribes came to attack. This event is called the Battle of the Trench or the Battle of the Confederates, which happened in the fifth year of Hijra (627 CE).
There is a chapter in the Quran called Surah Al-Ahzab (The Confederates) about this battle. The Prophet Muhammad (peace be upon him) used to pray:
"There is no god but Allah alone, who has honored His soldiers, helped His servant, and defeated the confederates alone; there is nothing after Him."
Allah gave the Muslims victory as the Quran says:
"O you who have believed, remember the favor of Allah upon you when armies came to you and We sent upon them a wind and armies you did not see. And ever is Allah, of what you do, Seeing."
(Surah Al-Ahzab, 33:9)
The enemies left defeated without fighting. In the area, there is now a mosque called the Mosque of the Trench and some small prayer spots on Mount Sal'.