Training
This happens when a Trainer uses his Pokemon to battle with Pokemons which are defending their Gym. The defending Pokemon can be owned by the the Trainer himself or by another member of the same Team. Training will increase the Trainer's level as well as the Prestige of the Gym. The higher the Prestige, the higher the Gym's level will get. Gyms with a higher level are harder to be taken over by other teams.
In order to be able to start training, your Team must first obtain a Gym. If another team owns it, the Trainer must battle and win in order to decrease the Prestige of the opposing Team. Once the Prestige has reached zero, the Gym will now be Neutral and the Trainer can now leave one of his Pokemons to defend that Gym. After owning a Gym, its color will now change to your Team's color (Red, Blue, Yellow).