Sayyiduna al-Walid bin Uqbah (may Allah be pleased with him) was once in Iraq and saw a sorcerer performing tricks: he would cut off a man's head and then restore it. People began to say: "Subhan Allah (Glory be to Allah)! He is bringing the dead to life." A righteous man from the Muhajirun was also there. He went away, and the next day, when the sorcerer began to perform his trick, he came with his sword and struck off the sorcerer's head, saying: "If he was so truthful, let him now bring himself back to life." Sayyiduna al-Walid (may Allah be pleased with him) ordered that he be handed over to Dinar, the keeper of the prison, who was a righteous man, and he imprisoned him. But he admired the man's conduct, so he said: "Can you escape?" He said: "Yes." He said: "Then go out; Allah will never question me about you."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب القسامة / 16502