1590s, "small bomb used to blow in doors and breach walls," from French pétard (late 16c.), from Middle French péter "break wind," from Old French pet "a fart," from Latin peditum, noun use of neuter past participle of pedere "to break wind," from PIE root *pezd- "to fart" (see feisty). Surviving in phrase hoist with one's own petard (or some variant) "blown up with one's own bomb," which is ultimately from Shakespeare (1605):
For tis the sport to haue the enginer Hoist with his owne petar ("Hamlet" III.iv.207).See hoist.
To be caught in one's own trap: “The swindler cheated himself out of most of his money, and his victims were satisfied to see him hoist by his own petard.” A “petard” was an explosive device used in medieval warfare. To be hoisted, or lifted, by a petard literally means to be blown up.