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).