All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
It is not confirmed that the Prophet said that killing a person is only done by beheading him with a sword. However, there is a weak narration which reads: “No legal retribution except with a sword.” [Ibn Maajah]. The scholars classified the narrators of this narration to be weak. On the contrary, it is confirmed that the Prophet applied legal retribution for killing a soul without the use of the sword. Al-Bukhari and Muslim reported that a Jew killed a maid by squeezing her head between two stones, so the Prophet ordered him to be killed in the same manner. It is for this reason that the preponderant opinion of the scholars is that legal retribution is to kill the killer in the same manner he committed the murder.
As regards death punishment for crimes other than murder, like imposing a corporal punishment for apostasy, homosexuality and for other crimes for which the Islamic Law did not determine the method of killing, then in principle this is done by beheading the person with a sword, as the Prophet said: “If it happens for you to kill (anyone for some justified reason), kill (him/her) humanely (in a perfect and kind manner).” Ibn Qudaamah said: “The killing in Islamic Law refers to the killing with a sword…and the best manner of killing is killing with a sword.”
Killing with a sword is the method of legal retribution practised at the time of the Prophet and this was well known to the companions to the extent that when they see that a person deserves death, one of them would say to the Prophet said: “Let me cut off his head.”