Muhammad's Muslims continued to raid and plunder Quraysh caravans, especially at Badr, and so it was decided by the Quraysh to advance on Medina and occupy it. The Quraysh needed military reinforcements, and so negotiated with the Bedouins to join them. A tribe of Jewish Arabs, the Banu Nadir, who had been expelled from Medina by Muhammad, offered to the Bedouins half of their crops if the Bedouins would participate. Other tribes also joined the effort: the Ghatafan, Ased, Salem, Murra, Fuzarah, and Shuja. This alliance was called the Confederacy.
A group of 7000-10,000 men were assembled to march on Medina, led by Abu Sufyan. Muhammad learned of their plans, and at the suggestion of Salman the Persian, Muhammad ordered a deep trench to be dug. Some of the tools used were loaned from the Banu Qurayza, another Jewish tribe. The Banu Qurayza, occupying an oasis near Medina, unlike the Nadir, tried to remain neutral. The material from the trench was thrown up on the Medina side, creating a high embankment from which the Muslims could shoot arrows or throw stones down on anyone trying to cross the trench.
The illustration shows the three contingents of Quraysh and their allies (the red arrows) approaching the trench. Uncertain of how to proceed across the barrier meant the "battle" became more of a siege, an unfamiliar tactic in Arabian warfare. Attempts to fight over a span of 20 days led to a half-dozen casualties among the Muslims and three of the Quraysh. The Quraysh gave up and went home.
That is too simplified, however. Muhammad tried to break up the Confederacy by negotiating with some of the different tribes, even offering bribes. I'll go into detail tomorrow about the Ghatafan, and what happened to the Banu Qurayza when they changed their stance.