Gym

Gyms are scattered around the world much like PokéStops, but are not as common. Trainers can use them to train their Pokémon or to battle with other trainers' Pokémon.

Observing a gym on the world map will tell you a lot about it.
 * Blue Gyms are claimed by Team Mystic.
 * Red Gyms are claimed by Team Valor.
 * Yellow Gyms are claimed by Team Instinct.
 * Grey Gyms are not claimed by any team.
 * Pokémon appearing above the gym are currently set to guard it, though if you tap the gym and scroll to the right, you may see additional Pokémon that are stationed there.
 * Lightning and rubble flashing above the gym indicates a battle is under way.

Unclaimed gyms appear grey and can be claimed simply by approaching it and assigning one of your Pokémon to it. Any Pokémon you assign to a gym will stay with that gym and be inaccessible to you until it is defeated by an opposing team member. Once a trainer has at least one Pokémon defending a gym, that trainer becomes eligible for the Defender Bonus.

Individual trainers can only leave one Pokémon to defend per gym, but gyms can be upgraded (or leveled up) to accommodate more and more Pokémon from other trainers of the same team. To do so, increase the gym's Prestige by winning friendly duel's with your team's Pokémon on that gym.

Strengthen a Gym
Assigning a single Pokémon to an open Gym will claim it for the trainer's team. Strengthening a friendly Gym is achieved by having other trainers assign their Pokémon to help defend it. Only one Pokémon, per trainer, can be assigned to a gym at any time.

An icon of a boxing glove with a star on it should appear on the bottom right of the screen; allowing the ability to train! When training Pokémon at a friendly Gym, the Gym's overall Prestige and level will increase. A single Pokémon must be selected in order to begin training. Training will end once the Pokémon defeats all of the defending Pokémon, faints, or time expires during battle.

As the Gym gains Prestige, its Prestige bar will fill up. When it is full, it will level up, and more Pokémon may be assigned to that gym. An unclaimed gym starts at level 2, allowing 2 Pokémon from separate trainers to be assigned. At level 3, it may have 3 Pokémon assigned, and at level 4, it may have 4 Pokémon assigned, etc. This continues until the Gym reaches the maximum level of 10.

Defense
Gyms gain Prestige through battles and by adding Pokémon to them. Trainers visiting a friendly gym can train their Pokémon, and the gym will gain experience/Prestige at the same time. Each time a gym's level increases, another Pokémon is allowed to join the gyms defense.

In training, you only have one Pokémon against the friendly gym's Pokémon team.

Trainers with at least one Pokémon defending a gym are eligible for the Defender Bonus.

You may only add a Pokémon to the Gym if it has a spot open (as shown with the icon to the right). If there is a spot open, there will be an icon on the lower left corner. If the gym loses a level, the Pokémon with the lowest CP will be removed. The removed Pokémon will faint and be returned back to its Trainer.

Attack
Trainers visiting an opposing gym may battle the defending Pokémon, in attempt to lower it's Prestige and eventually claim it for their team.

In Gym battles, you have a team of 6 Pokémon against the gym's Pokémon team.

Each successful battle will lower the gyms level by one, forcing it to remove one of its defending Pokémon. Defeating a level 1 gym will remove the last defending Pokémon, leaving the gym in a neutral state; ready to be claimed.

Multiple trainers can battle on a gym at once. If the trainers are fighting the same Pokémon, you will be able to see the other trainer's Pokémon attacking your opponent, even if you're not on the same team. The maximum; concurrent number of attacking trainers during a battle is 20.