Going to a Gym is where all the action usually is. It's the place to go when you've caught some great Pokémon and are ready to put their fighting skills to the test.
Gym's can usually be found dotted around the map and will usually be claimed by a certain team colour. The first time you enter a Gym you will be asked which team you wish to join. Choose carefully as you cannot change team later on.
Once you have joined a team and are ready to battle you can take on the current Gym leaders. Battles take on the form of real-time combat as opposed to the turn-based strategic battles of previous Pokémon games.
Providing the Gym you wish to do battle with is controlled by a different Pokémon team than yours you can do battle there. If the Gym is controlled by your team you can challenge the current residents to battle to increase the Gym's prestige. Do this enough times and you can increase the level of the Gym and create a new slot for you to insert your Pokémon into the Gym and make it even stronger.
Battling in a Gym
When it comes to the acual Pokémon battling, the methods of combat are fairly easy to get into. By tapping on the enemy you unlease a basic attack. If you press and hold down, you will release one of your creatures special attacks. You can also dodge incoming attacks by swiping left or right.
Gym leaders can be ejected from the Gym if you defeat them. How many times you need to defeat them depends on the Gym's prestige rating. Each battle you win will reduce the prestige until all the Gym members are gone.
When you have ejected all the Gym members the gym will become available to claim. You can tell it is ready to claim as it's colour will change to light grey. Some famous landmarks (London's Big Ben for example) have been turned into Gym's so taking over these high profile Gym's will give you something to brag about to your mates!
Cheating and Pokémon Gyms
There is a certain cheat that allows you to break a Gym and prevent other trainers from battling with the Gym members. Having an Egg in the Gym creates a glitch preventing others attacking the Gym. I've not tried it myself but the cheat involves placing an Egg in the Gym instead of a Pokémon. Whilst this probably works and allows you to amass a decent amount of Poké Coins without much hassle it spoils the game for others. Another reason for not attempting this cheat is now Niantic is aware of the cheat and are actively closing down the accounts of any trainer they suspect of playing outside the rules, so be aware!