The death penalty for apostasy is found more directly in the Qur’an — Islamic authorities generally root it in two Qur’anic verses, 2:217 and 4:89, as Hugh has noted.
Here is 2:217:
They ask thee concerning fighting in the Prohibited Month. Say: “Fighting therein is a grave (offence); but graver is it in the sight of Allah to prevent access to the path of Allah, to deny Him, to prevent access to the Sacred Mosque, and drive out its members.” Tumult and oppression are worse than slaughter. Nor will they cease fighting you until they turn you back from your faith if they can. And if any of you turn back from their faith and die in unbelief, their works will bear no fruit in this life and in the Hereafter; they will be companions of the Fire and will abide therein.
Meanwhile, 4:89 says this:
They but wish that ye should reject Faith, as they do, and thus be on the same footing (as they). But take not friends from their ranks until they flee in the way of Allah (from what is forbidden). But if they turn renegades, seize them and slay them wherever ye find them; and (in any case) take no friends or helpers from their ranks.
Here is 2:217:
They ask thee concerning fighting in the Prohibited Month. Say: “Fighting therein is a grave (offence); but graver is it in the sight of Allah to prevent access to the path of Allah, to deny Him, to prevent access to the Sacred Mosque, and drive out its members.” Tumult and oppression are worse than slaughter. Nor will they cease fighting you until they turn you back from your faith if they can. And if any of you turn back from their faith and die in unbelief, their works will bear no fruit in this life and in the Hereafter; they will be companions of the Fire and will abide therein.
Meanwhile, 4:89 says this:
They but wish that ye should reject Faith, as they do, and thus be on the same footing (as they). But take not friends from their ranks until they flee in the way of Allah (from what is forbidden). But if they turn renegades, seize them and slay them wherever ye find them; and (in any case) take no friends or helpers from their ranks.