Wikipedia
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.