Normally, the Ender Guardians are neutral and will attack players only if they hurt them first. If a player with Enderman Relic gets close to them, they will have a chance of detecting it and then start attacking that player.
They have 2 attacks, melee and explosion, and alternate between them very frequently. Every few seconds, they teleport away from the target, use explosion attack which launches the player into the air and gives the guardians a few seconds to get close to the him, and then start using their melee attack again.
There is no way of avoiding the explosion attack, so the best strategy is to have Blast Resistance and Feather Falling enchantments on your armor, along with a good sword to use against them during the melee phase.
It is also possible to get very close to another mob, such as Enderman, as the guardian's explosion attack will hit other mobs and make them attack him too.