Gym battles in Pokémon Go offer you three types of moves — basic attack, special attack, and dodge. Your first move in a Gym battle, even if your Pokémon has a higher power level and is strong against the Pokémon you're fighting, should always be a dodge. Slower Pokémon takes a second or two to launch their initial attack, but you will almost always dodge that initial assault and be ready for a counter-attack before the Pokémon in the center of the ring can catch up. This is especially useful if you're using super fast Pokémon, for example, any of the Eevee evolutions.
It's the difference between a close call and a guaranteed win almost every time. Swipe to the left or right as soon as the fight starts, and then lay into your opponent. When you see that yellow flash on the screen during a battle, it is also time to start dodging the enemy's attacks. Don't wait for the enemy to move, swipe as soon as you see the yellow flash.
Sneaky Swap OutAt some point in your career as a Pokémon Trainer, you're going to be standing next to a gym you control as it goes down. Maybe it's because you're outnumbered and can't maintain gym prestige, or maybe you just weren't paying attention. It's going to happen, but it doesn't have to be a moment of defeat.
If it looks like you're going to lose a gym, let it happen. Make sure your best Pokémon are healed up and keep an eye on the map. The second you see the Gym turn from your team color to plain white, recapture it by putting your freshly healed Pokémon there. The Gym prestige will immediately jump up, and it will take at least another two battles for your opponents to try reclaiming that gym again. With quick enough fingers, you can repeat this over and over again, frustrating your opponents to no end.