In battle
During harsh sunlight, Leaf Guard prevents the Pokémon from being afflicted by non-volatile status conditions and Yawn (including via the Flame Orb and Toxic Orb).
If a Pokémon with this Ability is drowsy due to Yawn, if there is harsh sunlight when it would fall asleep, the Ability activates and keeps it awake.
Generation IV
Leaf Guard does not prevent self-inflicted sleep from Rest.
Generation V onward
Leaf Guard now prevents the use of Rest.
Outside of battle
Leaf Guard has no effect outside of battle.