Rajm (رجم) is an Arabic word that means "stoning". It is commonly used to refer to the Hudud punishment wherein an organized group throws stones at a convicted individual until that person dies. Under Islamic law, it is the prescribed punishment in cases of adultery committed by a married man or married woman. The conviction requires a confession from either the adulterer/adulteress, or the testimony of four witnesses (as prescribed by the Quran in Surah an-Nur verse 4), or pregnancy outside of marriage.
No mention of stoning/Rajm or capital punishment for adultery is found in the Qur'an, which (in Surah an-Nur) prescribes lashing as punishment for premarital and extramarital sex (zina). For this reason some minority Muslim sects such as Kharijites found in Iraq, and Islamic Modernists such as the Quranists disagree with the legality of rajm.
However, stoning is mentioned in multiple hadiths (reports claiming to quote what the prophet Muhammad said verbatim on various matters, which most Muslims and Islamic scholars consider an authoritative source second only to Quran as a source of religious law) and therefore most Muslim and all Sunni and Shia schools of jurisprudence accept it as a prescribed punishment for adultery. Based on some contradict ayats such as at K.4:25 and K.24:2 some argue this ruling is likely an error. However, it is generally believed that not all rulings of Shariah are to be found in Quran. The Sunnah is considered as complementary which is used to derive some rulings not mentioned in the Quran in many respects. Therefore, majority of Muslim religious scholars both in past and at present times consider strength of textual evidences from Sunnah brought in various Hadith books as enough of proof for authenticity of this ruling.
At least a couple of sources (Sadakat Kadri, Max Rodenbeck) have noted that while popular in the abstract, rajm has been infrequently applied in Islamic history. Stonings were recorded just once in all the history of Ottoman Empire, and not at all in Syria during Muslim rule;) Techniques used to "minimize the possibility" that the pregnancy of a single woman would be considered evidence of zina and make justice more merciful, included "fantastic presumptions" about the length of the human gestation period. Classical Hanafite jurists ruling that rather than nine months, it could last for up to two years, Shafi'ites four, and Malikites as long as five years.Rashidun Caliph Umar once acquitted a pregnant single mother on the grounds that she was a "heavy sleeper" who had had "intercourse without realizing it".