How to Take Over Gyms and Become a Gym Leader
Each Gym has a prestige number that represents the CP of the Pokemon stationing it. By battling Gyms and winning, the Prestige will drop. If it hits zero, you will successfully take over the Gym for your team and need to place Pokemon there to defend it. If other members of your team drop by, they can also leave Pokemon. If your Pokemon has the highest CP, you will be deemed the Gym leader.