Came up with this:

A ‘petard,’ in medieval warfare was a metal and bell-shaped explosive charge (a crude hand grenade or mine) which took its name, oddly enough, from the French ‘peter,’ ‘to break wind.’ Daring warriors would affix to the walls or gates of a castle under siege. ...The explosive was detonated by a slow match or slow burning fuse. Occasionally, of course, the explosive went off prematurely, blowing up the man who lit it as well as the castle wall. Such a man was said to be ‘hoist’ (lifted or heaved) ‘by his own petard.’ Note that the ‘hoist’ in the passage is not the same as our modern "hoist"; it's an older form of the word, ‘hoise,’ with a participial ending that ends up as a -t (it would normally be written hoised).


It is unlikely that this archaic phrase would have persisted in our language, even in a figurative sense, had not Shakespeare conferred immortality upon it with his line from ‘Hamlet’ (~1600) when Rosencranz and Guildenstern are sent with Hamlet to England bearing orders that Hamlet be killed. Hamlet alters the orders so that they are killed instead. Hamlet then says: For 'tis the sport to have the engineer hoist with his own petard; and 't shall go hard, but I will delve one yard below their mines, and blow them at the moon. (Hamlet III.iv.206ff, spelling modernized). Today it is chiefly used to describe a person ruined by plans or devices with which he had plotted to ensnare others