Fiqh-us-Sunnah Volume 4, Funerals and Dhikr, Fiqh 4.049.

Section : Funeral Prayer for a Person Sentenced to Death for a Crime.

Anyone sentenced to death by an Islamic court is to be washed and a funeral prayer should be offered for him. This is based on a report by Bukhari that Jabir said: “A man from the tribe of Aslam came to the Prophet, peace be upon him, and confessed to fornication. The Prophet, peace be upon him, tried to avoid him four times, while the man repeated his testimony against himself. Then the Prophet, peace be upon him, asked the man: ‘Are you mad?’ The man said, ‘No.’ The Prophet, peace be upon him, asked him, ‘Are you married?’ He said, ‘Yes.’ Thereupon the Prophet, peace be upon him, ordered that the man be stoned to death. He was stoned to death at the place where (‘Eid prayer) used to be offered. When the stones struck the man, he tried to run away, but was overtaken and killed. After his death, the Prophet, peace be upon him, spoke well of him, and offered funeral prayer for him. Ahmad said: “We know of no cases where the Prophet, peace be upon him, refused to offer funeral prayer for any one except in cases of one convicted of embezzlement (of zakat funds) and a person who committed suicide.”