In 628 CE, the Muslims and the Meccans wrote a peace treaty so that Muslims could make the annual pilgrimage to Mecca for religious purposes. To back up the treaty, neighboring tribes were asked to choose sides and support their allies in the event of a treaty violation. Eventually, one of the allied tribes broke the agreement, and Muhammad decided to support his own ally, who had been attacked. By this time his forces outnumbered the Meccans, so he planned a surprise attack on the city of Mecca itself. Because the Meccans were unprepared for battle, they chose to surrender peacefully. Thus, in 630 CE Muhammad won back control of Mecca without shedding a drop of blood.