illustration (attribution, if any possible, is at the end of the article)
There are two main understandings of the relationship between a buddha and Evil.
An earlier conception is that a buddha has simply ceased all afflictions, all hindrances, all ignorance and is unrelated to Evil.
It is important to realise that this is 'unrelated', not 'against': the buddha is beyond lust and aversion so (s)he has no aversion towards Evil, (s)he simply has nothing to do with it…
The buddha is gone beyond mental categories such as Good and Evil: (s)he sees causality and appropriateness and the desire shared by all sentient beings to be free from struggle. Good and Evil are mere mental labels, and the buddha sees things as they are, without projecting labels onto phenomena.
A later conception is strongly influenced by the "Three Thousand Realms in a Single Thought Moment" doctrine by Zhiyi (智顗, 538–597) of the T'ien-t'ai school, a doctrine based on interpenetration of all phenomena (interpenetration due to their interdependence).
Teaching is one way for a buddha to manifest Wisdom, but teaching means being into the world, engaging with ignorant sentient beings, understanding their hindrances and afflictions. In short, manifesting buddhahood —teaching— is enough to bring a buddha into contact with Evil.
This is obviously most compatible with selflessness: a buddha has no separate nature which could be isolated from suffering, buddhahood lies not in separation from the world but in a different way to relate to the world (also known as the "samsara is nirvāṇa, nirvāṇa is saṃsāra" doctrine).
A consequence of contact with Evil combined with causality is that the buddha may experience evil thoughts! This is quite a different conception from the earlier doctrine.
What distinguishes a buddha from ordinary beings is the buddha's ability not to identify with such thoughts, not to perpetuate them: they arise, they cease, the buddha didn't act on them, nor did (s)he cling to them in any way.
This is what the freedom to choose what you act on brings (gplus.wallez.name/8n5MABskFWB): it lets Evil cease… not by fighting it, but by not giving energy to it, by not perpetuating it.
Of course the later conception reinforces the perspective that buddhahood is humanly possible: buddhahood doesn't rely on a separate state of unachievable purity of mind, never touched by any 'bad' thought.
It stresses that you are what you do: take responsibility for your responses, for your acts! This is of course compatible with e.g. the Vāsettha sutta (MN 98): « One born of a brahmin woman’s womb is not a brahmin. By address, he is sir, he has defilements; when he has no defilements and no seizings, I call him a brahmin. »
You do not "have to" act on bad thoughts, it's up to you, not the thoughts: you have buddha-nature! You don't need to fight them, you just have not to feed them.
It also stresses that when you project the "axis of Evil" or innate Evil onto others, you're seriously ignorant of selflessness: no one is inherently good or bad, what one decides to act on is what gives traits to the actor, these traits are not inherent…
A difficulty is of course that the ignorant doesn't know —by definition— that (s)he doesn't have to act on a thought, doesn't have to identify with it, doesn't have to appropriate it (moreover knowing so on an intellectual level is not yet knowing how to guard the mental door in practice).
The difficulty shouldn't be denied, but it doesn't make sense to blame people for what they don't know. If you understand this, compassion is a lot easier to manifest (and it doesn't take the shape of some 'holy' war, in which each side imagines being 'the' Good).
Buddhism is often caricatured as sitting on the fence with regards to "Good vs. Evil" by rejecting all absolute claims, but this is just a caricature. Buddhism simply accepts that projections are at play when we talk of Good and Evil, and that we forget the mind between awareness and reality (gplus.wallez.name/aVJ7pgjKZT6): what appears to us may be context-dependent (gplus.wallez.name/aeCr4KinJaw), but intentions do matter, it's not "all the same".
Scroll: A tengu and a Buddhist monk, by Kawanabe Kyōsai (1831–1889).