In Joan Aiken's "The Third Wish," the resolution sees Dido Twite outwit the dwarf by turning his own tricks against him. She deceives him into drinking a "magical" potion that transforms him into a harmless toad, then throws the toad into the well. This act frees the captive boy, allowing Dido and the boy to escape the castle.
Cleverness triumphs over magic—the third wish becomes the instrument of liberation, not the dwarf's intended trap.