Gym Battle

A gym battle is a battle in which a trainer challenges a gym leader for their badge. It also lets you get traded Pokémon and higher leveled Pokémon to listen to you. You can also use HM's (Hidden Machines) outside of battle.

In the Anime

Ash had traveled through many Gyms and overcame tough challenges to earn badges.