Ward triggers at a specific moment: when a spell or ability that targets the permanent with Ward is first cast or first activated (CR 702.20b). The trigger occurs immediately at that point, before any player receives priority or any other game actions happen. It does not monitor the spell's targets throughout its existence on the stack.
If a target later becomes illegal — for example, because the permanent was given hexproof, bounced back to hand, or destroyed in response — the spell or ability simply loses that target. Under CR 608.2b, when a spell or ability resolves, if all of its targets are illegal, it is countered by the game rules. Ward's trigger has nothing to do with this process; it already fired (or didn't) the moment the spell was cast.
The reverse edge case: if Ward is gained after a spell is already on the stack targeting the permanent, Ward does not trigger retroactively (CR 702.20b requires the spell target the permanent "as it was cast or activated"). Ward only cares about the moment of casting or activation.
Concrete example: Your opponent casts Lightning Bolt targeting your Ledger Shredder (which has Ward 2). Ward triggers immediately when Bolt is cast, and your opponent must pay 2 or Bolt is countered by Ward. Now suppose before Ward resolves you cast Giant Growth on Ledger Shredder and your opponent responds by bouncing it with a cantrip. Ledger Shredder is no longer on the battlefield, so Lightning Bolt's target is now illegal — but Ward's trigger already happened earlier; the bounce only means Bolt itself will be countered by game rules for having no legal targets, not by Ward again.
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.