In DN 1, the Buddha saysexplains how to deal with people who insults the Buddha, the Dhamma or the Sangha:
“If, bhikkhus, others speak in dispraise of me, or in dispraise of the Dhamma, or in dispraise of the Sangha, you should unravel what is false and point it out as false, saying: ‘For such and such a reason this is false, this is untrue, there is no such thing in us, this is not found among us.’
The following are a few excerpts from the sutras on how the Buddha dealt with and instructed his disciples to train when thoughts of anger and ill will are present:
[...] As I abided thus, diligent, ardent and resolute, a thought of [sensual desire, ill will, cruelty] arose in me. I understood thus: 'This thought of [sensual desire, ill will, cruelty] arose in me. This leads to my own affliction, to others affliction, and to the affliction of both; it obstructs wisdom, causes difficulties, and leads away from Nibbāna'. When I considered: 'This leads to my own affliction', it subsided in me; When I considered: 'This leads to others affliction', it subsided in me; When I considered: 'This leads to the affliction of both', it subsided in me; When I considered: 'This obstructs wisdom, causes difficulties, and leads away from Nibbāna', it subsided in me. Whenever a thought of [sensual desire, ill will, cruelty] arose in me, I abandoned it, removed it, did away with it.
Bhikkhus, whatever a bhikkhu frequently thinks and ponders upon, that will become the inclination of his mind. [...]
But with excessive thinking and pondering I might tire my body, and when the body is tired, the mind becomes strained, and when the mind is strained, it is far from concentration. So I steadied my mind internally, quieted it, brought it to singleness, and concentrated it. Why is that? So my mind should not be strained.
-- Dvedhāvitakka Sutta [Bodhi trans.], MN 19
and:
[...] If, while he is examining the danger in those thoughts, there still arise in him evil unwholesome thoughts connected with desire, with hate, with delusion, then he should try to forget those thoughts and should not give attention to them. When he tries to forget those thoughts and does not give attention to them, then any evil unwholesome thoughts connected with desire, with hate, and with delusion are abandoned in him and subside. With the abandoning of them his mind becomes steadied internally, quieted, brought to singleness, and concentrated. [...]
If, while he is trying to forget those thoughts and is not giving attention to them, there still arise in him evil unwholesome thoughts connected with desire, with hate and with delusion, then he should give attention to stilling the thought-formation(*) of those thoughts. [...]
If while he is giving attention to stilling the thought-formation of those thoughts, there still arise in him evil unwholesome thoughts connected with desire, with hate, and with delusion, then, with his teeth clenched and his tongue pressed against the roof of his mouth, he should beat down, constrain and crush mind with mind(*) (**).
-- Vitakkasanthāna Sutta, [Bodhi Trans.] MN 20
(*) "relaxing of thought-fabrication", per Thanissaro Bhikku
(**) "crush his mind with his awarenes", per Thanissaro Bhikku
(***) "crush unwholesome states of mind with wholesome states of mind", per Majjhima Nikāya Atthakathā