Hoist with your own petard
Injured by the device that you intended to use to injure others.
The phrase 'hoist with one's own petard' is often cited as 'hoist by one's own petard'. In the USA, 'hoisted' is preferred so the alternative forms there are 'hoisted with one's own petard' is often cited as 'hoisted by one's own petard'.All the variants mean the same thing, although the 'with' form is strictly a more accurate version of the original source.
A petard is, or rather was, as they have long since fallen out of use, a small engine of war used to blow breaches in gates or walls. They were originally metallic and bell-shaped but later cubical wooden boxes. Whatever the shape, the significant feature was that they were full of gunpowder - basically what we would now call a bomb.
The device was used by the military forces of all the major European fighting nations by the 16th century. In French and English - petar or petard, and in Spanish and Italian - petardo.
The dictionary maker John Florio defined them like this in 1598:
"Petardo - a squib or petard of gun powder vsed to burst vp gates or doores with."
The French have the word 'péter' - to fart, which it's hard to imagine is unrelated.
Petar was part of the everyday language around that time, as in this rather colourful line from Zackary Coke in his work Logick, 1654:
"The prayers of the Saints ascending with you, will Petarr your entrances through heavens Portcullis".
Once the word is known, 'hoist by your own petard' is easy to fathom. It's nice also to have a definitive source - no less than Shakespeare, who gives the line to Hamlet, 1602:
"For tis the sport to have the enginer Hoist with his owne petar".
Note: engineers were originally constructors of military engines.
See other phrases and sayings from Shakespeare.