I would say for a defender all 3 are important:
ATK contributes the most to CP which ranks you higher in gym, HP makes your mon last longer which means more damage dealt and DEF is self explaining.
for an Attacker it depends on your preference, ATK shortens the fight, DEF is not very important but makes you use less potion and HP is just important if you have trouble cleaning the gym. Maybe I should mention if you prestige a friendly gym it is useful to have low CP mons to get more prestige, so it can be useful to have an attacker with low ATK