Originally posted by otheadp
It's called "Treaty of Hudaibiya" (in the year 628)
As you know, wars were fought between the Quraish and the Muslims. The Quraish lived in Mecca and wished to crush Islam. However, after the Battle of the Ditch, the Muslims had the upper hand. Because of this, the Holy Prophet decided to visit Mecca.
The Quraish learned of this and sent 200 horsemen to intercept the Muslims and prevent them from entering Mecca. After a discussion, the Muslims decided to continue to Mecca. If the Quraish chose to fight, they would too. Otherwise, not. However, an alternative route was found and the Muslims reached Hudaibiya on the lower side of Mecca, which was within the sacred territory for the pilgrimage.
A diplomatic was sent by the Quraish. Then one by the Muslims. The Muslim diplomatic did not return for three days and a rumor had become afloat that he was killed by the Quraish. But then Othman, the Muslim diplomatic returned with a Quraish diplomatic, Suhail. A treaty was negotiated upon. Treaty of Hudaibiya.
1. There was to be a truce for ten years between the Muslims and the Quraish.
2. If any tribe wished to enter into treaty with the Muslims, it could do so, and whoever wished to enter into a treaty with the Quraish was also free to do so.
3. If any one from the Quraish came to the Muslims and was converted to Islam, he was to be returned to the Quraish. On the other hand, if a Muslim sought refuge with the Quraish, he was not to be delivered to the Muslims.
4. In addition, the Muslims would withdraw that year without performing the Hajj, but they would be free to perform the Hajj the following year when they could stay in Mecca for three days.
Notice that this was in favor of the Qurarish. Both sides agreed to this. However, when women came to the Muslims, a crisis emerged. The Quraish wanted the women to be returned to them. However, the Holy Prophet refused too saying that this did not apply to women:
"Believers, when believing women came to you as refugees, examine them. Allah knows the state of their faith. If you find them to be true believers do not return them to the unbelievers. They are not lawful to the unbelievers, nor are the unbelievers lawful to them You shall, however, give to their former husbands what they have spent on them. And you will be doing nothing unlawful after you have given them dowries." 60: 10
Dowries were given. However, a Quraish force was gathering together against the Muslims. So before the Holy Prophet decided that the enemy gather strenght, that the Muslims should fall upon and break their power.
This is probably the surprise attack I assume you are referring too. Although this may seem as a dishonorment of the Holy Prophet's word, it is not. The Word of God is more bigger and wiser than the word of man. Although the Hudaibiya Treaty was in favor of the Quraish, it brought the victory of Islam all over Arabia. It ended in a almost bloodless victory at Mecca. People between Mecca and Medina could now meet peacefully and were able to travel freely.