I try to always be good to everybody. Because of that, people tend to be nice to me, so I seldom have the opportunity to experience ill-will towards anybody. However, no matter how good you are to people, there is always a non-zero probability that somebody will hurt you very badly every now and then. On very rare occasions, somebody hurts me so deeply I even experience hatred.
The last time I experienced hatred, I learned something of profound importance. After I was able to calm the mind (which required all my meditative training and every last ounce of my mental energy, by the way) the mind began to develop the ability to clearly see the suffering arising from hatred. First, the mind was able to clearly perceive when it was in a non-hatred state and to rest in that state. When hatred arose (which happened many times a day when I was most deeply hurt), the mind was strongly drawn to it, and then just after it crossed the threshold into hatred, it immediately recognized the suffering arising from it. In this state, the mind could clearly see there there is nothing here but pain and suffering. And mind understood that hatred is painful like a naked fire burning one's hand and that withdrawal from it is the only choice. So mind withdrew back into the state of non-hatred just as one's hand instinctively and effortlessly withdraws from a naked fire.
The clear mind is fascinating to behold.
This is an extremely important lesson to me. It suggests that the best way to overcome hatred is to develop the clear insight that hatred is nothing but a painful state of mind. There is nothing in there but suffering, suffering, and more suffering. When the mind can see it that clearly, it quickly, instinctively and effortlessly withdraws from hatred, like one's hand withdrawing from fire. Because of that, it no longer suffers from hatred.
Thus, insight brings about freedom from hatred.
I suspect this is true not just of hatred, but also of all mental afflictions. If we are able to clearly perceive the nature of suffering in them, we will then quickly, instinctively and effortlessly withdraw from them like we withdraw from fire. And eventually, we will be free of those afflictions.
I think that is why the Buddha said, "Monks, all is aflame ... Aflame with the fire of greed, the fire of hatred, and the fire of ignorance." Seeing thus, one is free from greed, hatred and ignorance.