On the authority of Ibn Masood (may Allah be pleased with him) who said:
The Messenger of Allah (peace and blessings of Allah be upon him) said, "It is not permissible to spill the blood of a Muslim except in three [instances]: the married person who commits adultery, a life for a life, and the one who forsakes his religion and separates from the community."[Al-Bukhari][Muslim]
Reference: 40 Hadith Nawawi 14
English translation: Hadith 14