Gyms is a kind of location in Pokemon Go.
Once you reach level 5, you will be able to join a team by tapping on any Gym in the world. Once you have chosen a team then you will be able interact with a Gym.
A number of gyms now have PokeStop built into them.
Access the Poke Stop
Pokemon Gyms with this Icon in them have a Poke Stop built into them. Tap this icon to access it.
Joining a Gym
If you are aligned with the team that presently controls the Gym you reach, then you can deposit a Pokemon into it. As long as that Pokemon remains in the gym you will get a Defender Bonus. If the Gym is taken over, then the Pokemon you deposited it immediately returned to your stock. This is done by tapping the icon in the lower left-hand corner of your screen when you are looking at the gym. Pokemon Gyms can now only have 1 Pokemon of each type in them (You can have 1 Jolteon, 1 Vaporeon, but no doubles).
Pokemon will only leave a Gym when their motivation has completely drained or they have been defeated.
Pokemon in a Gym now have a motivation state. The higher Motivation they have, the higher their Maximum CP is. As their motivation lowers, so will their CP. When completely drained, they will leave the Gym. Motivation is restored by feeding the Pokemon in the Gym Razz Berries.
Fighting a Gym
When you challenge a Gym, you can choose 6 Pokemon to contest the Gym with. Your victory will result in the loss of prestige for that Gym. When the Prestige is lowered to Zero, then you will have the chance to take over the Gym for your team and turn it into an Allied Gym. Before you challenge a Gym, look into what Pokemon are defending it. You can swipe through the roster while you are looking at the Gym itself. The more times the Pokemon are defeated, the more disheartened they will become and the lower their CP will become.
Strengthening a Gym/Prestige Level - Old
Each gym has an amount of Prestige. By training your Pokemon at an allied Gym, you will be able to increase the prestige. The more prestige a Gym has, the more Pokemon can be stored here to defend it. More Pokemon are added every 4000 Prestige that a Gym has gained (4000/8000/12000). Each Gym can only have 3 Pokemon stored in it. To this end, it helps a lot to have a lower CP Pokemon in the first Pokemon Slot of the Gym for ease of grinding.