Sayyiduna Ali (may Allah be pleased with him) narrates that when he caught a thief, he would cut off his hand, then cauterize it, then put him in prison. When they had recovered and he wanted to release them, he said: Raise your hands to Allah. (The narrator said:) It is as if I am looking at them, as though they were donkeys' members. He would say: Who cut off your hands? They would say: Ali (may Allah be pleased with him). He would say: O Allah, they have spoken the truth; for Your sake I cut them, and for Your sake I released them.
The Shaykh (may Allah have mercy on him) said: It seems he used to order that they be looked after until they healed, not that he imprisoned them as a ta'zir (discretionary) punishment.
Sayyiduna Ali (may Allah be pleased with him) said: For the ruler to imprison [a person] after the hadd has been carried out is injustice.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السرقة / 17258