Fight fire with fire
Respond to an attack by using a similar method as one's attacker.
When we 'fight fire with fire' we are likely to employ more extreme methods than we would normally do. That was what Shakespeare was referring to in King John, 1595:
Be stirring as the time; be fire with fire;
Threaten the threatener and outface the brow
Of bragging horror
The Bard may have been the first to put the notion on paper, but he didn't coin the phrase 'fight fire with fire', that came much later.
The source of this phrase was actual fire-fighting that was taken on by US settlers in the 19th century. They attempted to guard against grass or forest fires by deliberately raising small controllable fires, which they called 'back-fires', to remove any flammable material in advance of a larger fire and so deprive it of fuel. This literal 'fighting fire with fire' was often successful, although the settlers' lack of effective fire control equipment meant that their own fires occasionally got out of control and made matters worse rather than better. One such failure was recorded in Caroline Kirkland's novel, based on her experiences of frontier Michigan in the 1840s, A New Home - Who'll Follow? Or, Glimpses of Western Life (written under the pseudonym of Mrs. Mary Clavers):
The more experienced of the neighbours declared there was nothing now but to make a "back-fire!" So home-ward all ran, and set about kindling an opposing serpent which should "swallow up the rest;" but it proved too late. The flames only reached our stable and haystacks the sooner,
The method has continued to be used however and foresters now routinely create roads or unplanted areas to act as fire-breaks in woodland that is at risk of fire.
The term 'backfire' is now more often applied to plans that fail in a way that weren't intended. This might be assumed to derive from the faulty 'flash in the pan' tendency of early flintlock weapons. That isn't the derivation in fact. 'Backfire' wasn't used in that negative sense until the early 20th century and derives from the popping explosions that used to be commonly heard from the exhausts of motor vehicles, not from guns, which weren't said to backfire until WWI, or from forest 'back-fires' which ran out of control.
The earliest usage of 'fight fire with fire' that I've found in print is in the US author Henry Tappan's 1852 reminiscence A Step from the New World to the Old, and Back Again:
Smoking was universal among the men; generally cigars, not fine Havanas, but made of Dutch tobacco, and to me not very agreeable. I had some Havanas with me, and so I lighted one to make an atmosphere for myself: as the trappers on the prairies fight fire with fire, so I fought tobacco with tobacco.