Treaty of Hadaibiyyah
Bokhari has related, on the authority of Braa bin Aazib, that in the treaty of Hudaibiyyah, the Holy Prophet, peace be on him, agreed with the pagans of Mecca that if anyone of them became a Muslim and came to Medina, he would be returned to the Meccans, but that if a Muslim departed from Medina and joined the Meccans, they would not be under obligation to return him to the Holy Prophet (Bokhari, Egyptians edition, Vol. II, p. 76).
The obligation undertaken by the Holy Prophet in the treaty that a Muslim who departed from Medina and joined the Meccans, which means that if he repudiated Islam and went and identified himself with the Meccans, he would not be restored to the Holy Prophet, also establishes that apostacy was not punishable as an offence. Had it been punishable as an offence, the Holy Prophet would not have accepted this term of the treaty. He would have told the Meccan envoy, who represented the Meccans at Hudaibiyyah, that he could not agree to a term which was contrary to the divine command that an apostate was punishable with death. Nor did any of the Companions of the Holy Prophet protest against this term of the treaty that it was inconsistent with a Divine commandment.