Just like the traditional Pokémon game, you can encounter a gym and battle to become aspiring Pokémon master. Gyms are towering, spinning monuments found out in the wild, which can be captured with gym battles defended by increasing their prestige level. You can join a team once your Trainer level hits 5; when you next interact with a Gym, Professor Willow invites you to join one of the game's three teams - Team Instinct, Team Mystic, or Team Valor.
The differences between the teams are purely cosmetic, but it's worth siding with the same team as a friend, allowing you to tackle Gyms easier. Once you have joined a team, you can help defend or challenge Gyms at your leisure.
Gyms can have multiple Pokémon assigned to defend it, the number of which is dependent on its Prestige; the higher the level, the more Pokémon that can be stationed there, making it harder to be taken over down by rival factions.
If a gym is a grey, neutral colour, then it is currently unclaimed, and you are free to claim it for your team by gifting a Pokémon to it. It's rare you'll actually see unclaimed Gyms out in the wild now the game is available, but if you manage to remove a rival team that Gym will then resume back to a neutral state - so be quick to claim it for your own before a rival team takes it.
You don't have to be close to a Gym to check out the team and Pokémon stationed there, but it's important to remember you have to be physically near a Gym for the entirety of your time with it - so don't try and take on a Gym when you're train has pulled into a station for 30 seconds, otherwise you'll be booted out when you move away. Between that and the fact that a series of battles can take a while to complete, it's well worth planning your Gym activities in advance.
Pokémon Go - friendly and rival Gyms
What you can do at friendly Gyms:
If visiting a Gym claimed by your team, it's worth taking a look to see the Prestige level and the amount of Pokémon stationed there. A level three Gym can house three Pokémon, for example, so if there are fewer creatures than the level, it means there is a space in the ranks, and you can drop in one of your Pokémon to help defend it. (Note that the chosen Pokémon will leave your inventory and remain at the gym until it's kicked out, so pick carefully!) To see what you get for defending a gym, see the rewards section below.
You can also help by Training - the practice of sparring with the Pokémon that are there to raise the gym's Prestige level, earning yourself XP and raising the Gym's prestige for doing so.
What you can do at a rival Gym:
At a rival gym, you can take up to six Pokémon into battle and fight the creatures in residence in order of CP level. Each Pokémon you defeat lowers the Prestige level a little and defeating the leader will reduce it significantly - though not entirely - so expect to make multiple attempts in order to neutralise the gym.
Even if you aren't powerful enough to take on every Pokémon, it's still worth getting as far as you can before fleeing the battle. You will still get a decent chunk of experience for taking part (150XP per win) and help chip away at the Prestige level.
It's also possible for multiple Trainers to fight in a gym at once, even if you're from rival teams.
Pokémon Go - Training at friendly Gyms
Training in Pokémon Go is likely to become a pretty important mechanic as the game progresses over time, with your Team's control of the Gyms rumoured to be a part of finding the Legendary Pokémon, and reliable XP harder to find - and more valuable - once you reach a higher level. With that in mind, here's everything you need to know about Training in Pokémon Go:
Training is the practice of battling yours or your own Team's Pokémon at friendly, Team-controlled Gyms, for the purpose of raising the Gym's prestige and earning yourself significant amounts of XP in the process.
The XP earned from training is equal to 10 percent of the Prestige gained.
The maximum Prestige gained from defeating a single Pokémon through Training is 1000 - and therefore the maximum XP per defeated Pokémon in Training is 100XP.
Thanks to keen-eyed trainer SneakyKs on the Silph Road subreddit, it's been confirmed that you actually get a greater amount of Prestige if you use lower CP Pokémon to attack than the Pokémon which is defending. The example they use is a 733 CP Sandlash taking down a 1314 CP Arcanine that was defending, granting an impressive 896 increase in Prestige. Be sure to check out the post to see the exact nitty gritty of the formula involved. For more on CP, by the way, you can check out our Pokémon Go CP explainer.
You can only enter one of your Pokémon into battle at a time, and if you're mostly after XP gains, then you may do better by battling rival Gyms instead, which gives you the added benefit of chipping away at their Prestige, too.
Pokémon Go - Gym battle strategies
While the main Pokémon games are surprisingly complex role-playing games, Pokémon Go has a simplified, real-time battle system that comprises of three moves - a regular attack by tapping the screen, a special attack which builds as you fight that can be unleashed by holding the screen, and a dodge that's performed by swiping left and right.
There is little strategy beyond swiping when you believe attacks are coming in (the more powerful special attacks are much easier to avoid thanks to their early tells) and spamming regular attacks with an occasional special attack whenever you can. The main points of note here are:
You can anticipate an incoming attack by watching for the yellow "flash" on the screen - look to dodge immediately after seeing that. It's possible to take down an entire Gym without taking damage, if you have some particularly prodigious reflexes.
Defending Pokémon have double HP, to compensate for the fact that they're managed by the AI and thus can't dodge or use much strategy in their attacks. That means placing high-HP Pokémon in Gyms, such as Snorlax, Lapras, or Vaporeon, is a more efficient way to defend than with strong attackers.
Not all special attacks are worth using. Sometimes, a high damage, high-speed quick attack can deal out more DPS than a slow, medium-damage special attack. Keep an eye out for what works in-battle, and avoid relying on your special attacks without doing some research first.
With combat being relatively simple, there are two other factors that are much more important than your tactical prowess; a Pokemon's CP and Type. You essentially want your CP to be as high as possible - ideally one or two hundred more than the rival - in order to better withstand attacks and do damage.
Less important but still helpful in battle is the Type, allowing attacks of a certain element - such as Water attacks against a Fire Type - to do more damage. Whether you're new to the franchise or need a refresher on what element trumps what, we've got a handy Pokémon Go Type chart, including Type advantages and weaknesses, to help you out. Likewise, STAB - same-type-attack-bonus - makes a return from the main series too, modifying attacks of the same type as the Pokémon using them by 1.25. An example would be the Water-Type Pokémon Blastoise using the Water-Type move, Water Gun.
Pokémon Go - Gym rewards: How to get PokeCoins for free
Battling in Gyms will give you XP points - 50XP for sparring in a friendly gym, and 150XP for a battle in a rival Gym - making it not a decent way to earn experience.
But placing a Pokémon in your inventory at a gym to defend it, you will then be rewarded 10 PokéCoins and 500 Stardust every 21 or so hours, which can be claimed from the Shop menu - providing your Pokemon hasn't been knocked out of that gym.
You can store up to 10 Pokemon at gyms at any one time, and you'll get them back if and when they are removed.