Lifelink is defined in CR 702.15a: whenever a source with lifelink deals damage, its controller gains that much life. The rule makes no distinction about what is being damaged — it applies to damage dealt to players, planeswalkers, creatures, or any other permanent or player that can be dealt damage.
When a creature with lifelink attacks and is redirected to deal damage to a defending planeswalker (or attacks a planeswalker directly, since planeswalkers can be attacked under CR 306.8), the damage is still dealt by that creature. Because the source of the damage has lifelink, its controller gains life equal to the damage dealt (CR 702.15b).
It does not matter that a planeswalker loses loyalty counters as a result of combat damage rather than a player losing life — the damage event itself is what triggers lifelink, not the life-loss event on the defending player's side.
Concrete example: You attack your opponent's Liliana, Dreadhorde General (5 loyalty) with a 3/3 creature that has lifelink. Your opponent blocks with nothing, so the creature deals 3 damage to Liliana, removing 3 loyalty counters. Because the creature has lifelink, you simultaneously gain 3 life.
This is consistent with CR 120.3, which lists planeswalkers among the permanents that can be dealt damage, and CR 702.15b, which ties life gain to the act of dealing damage rather than to the type of object receiving it.
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.