At the heart of the biggest update to Pokémon GO is a new motivation system that will significantly change how players interact with Gyms. When a Pokémon is assigned to a Gym, a motivation meter will be displayed. Pokémon assigned to defend a Gym lose motivation over time and as they are defeated in battle. As a Pokémon loses motivation, its CP will temporarily decrease, making it easier for opposing teams to defeat. To help keep the Pokémon motivated and in tip-top shape for their next battle, Trainers can treat their team’s Pokémon to some Berries, which restore their motivation. If a Pokémon loses all motivation, it will leave the Gym and return to its Trainer the next time it loses a battle, so you’ll want to keep your team’s Pokémon motivated by giving them Berries frequently.
Source: Pokémon GO blog