Hamlet:Hamlet Act 3, scene 4, 202–209
There's letters seal'd, and my two schoolfellows,
Whom I will trust as I will adders fang'd—
They bear the mandate, they must sweep my way
And marshal me to knavery. Let it work;
For 'tis the sport to have the enginer
Hoist with his own petard, an't shall go hard
But I will delve one yard below their mines
And blow them at the moon.
"Hoist with his own petard" literally means "blown up with his own mine." More generally, a "petard" is a hat-shaped device which can be be charged with gunpowder. Here's how Hamlet arrives at the phrase:
The prince—having "caught the conscience" of the murderous King Claudius [see THE PLAY'S THE THING]—is about to be packed off on a little vacation to England. He apparently hasn't been feeling too well in the head, so the king orders Hamlet's old school chums Rosencrantz and Guildenstern to keep him company. Though the two fools are relatively innocent (for spies), Hamlet knows that Claudius has some "knavery" planned and that Rosencrantz and Guildenstern are the king's tools.
Hamlet has already guessed that the letters his schoolfellows are carrying to the English court bear a "mandate" for his immediate execution. The prince intends to hoise this mine in the king's face. Claudius is the "enginer," the deviser of the explosive; and his plot is about a yard shallower than that of his nephew, who will send Rosencrantz and Guildenstern to the fate intended for himself.