When a spell or ability tries to resolve, the game checks whether its targets are still legal at that moment. If a target has become illegal by the time the spell would resolve, the spell is countered by the rules — not by a player — and its effects do not happen.
Hexproof means the creature cannot be the target of spells or abilities your opponents control (CR 702.11b). If a creature gains hexproof after being targeted but before the spell resolves, it is now an illegal target. The game checks target legality upon resolution per CR 608.2b, which states that if all of a spell's targets are illegal at that point, the spell is countered and does nothing.
It is important to note the targeting itself was perfectly legal when the spell was cast — hexproof only prevents new targeting, not targeting that already occurred. The issue arises solely at resolution, when the target check fails.
Concrete example: Your opponent casts Lightning Bolt targeting your Grizzly Bears. In response, you cast Dive Down on the Bears, giving it hexproof until end of turn. When Lightning Bolt tries to resolve, it checks its target and finds the Bears now has hexproof, making it an illegal target. Lightning Bolt is countered by the rules and the Bears survive.
If a spell has multiple targets and only some become illegal, the spell still resolves but does nothing to the illegal targets (CR 608.2b). However, when all targets are illegal, as in a single-target spell like Lightning Bolt, the spell is fully countered.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.