The battle of the Trench occurred in the month of Shawwāl during the sixth year after hijrah, the Jews pledged support to the Quraish and anyone else
who swore oath to fight the Prophet صلى الله عليه وسلم and his companions. The Quraish joined forces with Banu Sulaim, Banu Asad, Fazārah, Ashja’ and other than them, they came to Al-Madinah with ten thousand men.
Salmān Al-Fārisi advised the Prophet صلى الله عليه وسلم to build a trench that would protect them from the combined forces. The Prophet set out with three thousand men. He used the mountain of Sal’a as a protection from behind and the trench as a protection in front of him. The Prophet صلى الله عليه وسلم had entered a pact with the tribe Banu Quraydah, however they broke the covenant and joined the combined forces fighting against the Prophet صلى الله عليه وسلم .The Prophet صلى الله عليه وسلم then sent Nu’aym ibn Mas’ud to the combined forces and deceived them within their own ranks and caused them to split. Allah then sent an army from the wind demolishing their camps turning upside down their cooking pots, they were shaken by the winds and fear entered their hearts until they fled and abandoned the battle having attained nothing from their plots.
The Prophet صلى الله عليه وسلم then returned to Banu Quraydah and appointed Sa’d ibn Mu’ādh as the one to judge their affair. This is the battle that surah Al-Ahzāb had been revealed about.