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). It has no effect on any current status condition prior to the weather being set up.
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
Rest can still be used normally, and the user falls asleep for two turns.
Generation V onward
Rest will now fail if used by a Pokémon with Leaf Guard during harsh sunlight.
Outside of battle
Leaf Guard has no effect outside of battle.