If the person from whom the theft was committed pardons the thief before the matter reaches the ruler, the hadd punishment is dropped, but not after it reaches the court, because the hadd has now become obligatory.
➊ It is narrated from Abdullah ibn Amr (may Allah be pleased with him) that the Messenger of Allah ﷺ said:
تـعـافـوا الحدود فيما بينكم فما بلغنى من حد فقد وجب
“Pardon one another in matters of hadd punishments, and whatever reaches me (know that) it has become obligatory.”
[Sahih: Al-Silsila al-Sahiha: 1638, Abu Dawud: 4376, Kitab al-Hudud: Bab al-Afw an al-Hudud ma lam Tablugh al-Sultan, Nasa’i: 70/8, Hakim: 383/4]
➋ When the Messenger of Allah ﷺ ordered the hand of a thief to be cut off, the one from whom the theft was committed said: “I have given this item to him as a gift.” So the Messenger of Allah ﷺ said:
هلا كان قبل أن تأتيني به
“Why did you not do this before bringing him to me?”
[Sahih: Irwa al-Ghalil: 2317, Abu Dawud: 4394, Kitab al-Hudud: Bab man Saraqa min Hirz, Ahmad: 466/6, Muwatta: 834/2, Ibn Majah: 2595, Hakim: 380/4, Nasa’i: 255/2, Ibn al-Jarud: 828]
(Abu Hanifa, may Allah have mercy on him) The hadd is dropped due to the pardon even after the matter has reached the ruler.
[Al-Mabsut: 186/9]
(Shawkani, may Allah have mercy on him) The hadith refutes this (the position of Abu Hanifa, may Allah have mercy on him).
[Nayl al-Awtar: 582/4]