In battle
During harsh sunlight, Leaf Guard prevents the Pokémon from being afflicted by non-volatile status conditions (including via Flame Orb and Toxic Orb) and Yawn. It has no effect on any status conditions the Pokémon was afflicted by prior to the weather being set up.
If harsh sunlight is created in the turn where a Pokémon made drowsy due to Yawn would fall asleep, the Ability will activate and keep the Pokémon 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.