Head to the place where you dress up your Pokemon. The leader will be standing in your way there, and she leaves once you show up.
Your mum then hands you a suit. Take it, enter the contest, win it, and the gym opens up after that.