Only defend yourself to them one time per incident, if need be. Defending yourself one time is an assertion. Defending yourself multiple times is an entanglement. If they are being argumentative with you, clearly state your intention and defense once and then let it go. Leave the rest open to interpretation. The thing about toxic people is that they have boundless energy for drama, so don't start something that you can't finish with them. Do not argue with them because you will lose.
Recognize that you are being baited. It is a knee-jerk reaction to respond angrily to toxic people, but that is exactly what most of them want from you. They want to ruin your day and hope to make you a companion in their suffering. The simple act of recognizing and acknowledging that you are being manipulated into reacting negatively is usually enough to give you the strength to practice restraint of stooping to the level of their behavior.
Find out what they love and value in life, and keep conversations on those topics as much as possible. If this is a person that would be difficult to cut out of your life like a family member or colleague that you work closely with, it is best to find out the topics that bring out the best in them and stay focused on those. Don't complain about a person being toxic, yet continue to bring up topics that indulge their toxicity.
Try to find out or consider their background story for insight into why they're so miserable. Learn about their stories. You can either ask them directly or perhaps ask their friends about their lives. It is much easier to have compassion for someone toxic if you understand why they behave in the way they do.
Analyze your own toxic behaviors. Don't complain about toxic people when you are frequently backstabbing, lying, indulging in jealousy and complaining yourself. The more toxic people you have in your life, the more you need to honestly assess whether or not you're doing anything to attract these people. You may just be going through a rough patch in life, but it is still worthy of an assessment to make sure that you aren't contributing to this problem. Upgrade your moral conduct and then notice whether or not you have as many toxic people in your life.
Cut them out of your life if possible. This may seem like a common sense answer, but you would be surprised at how many people keep toxic people in their circles in an effort to change them. Stop trying to convert someone who acts in a predominantly toxic manner into a saint if it is causing you anguish. Move on. It is important to be surrounded by people who inspire us to act in a virtuous manner, not people who bring out the worst in us.
Work to eliminate your triggers. What wounds are the toxic person hitting up against? Childhood issues? Marital problems? Ask yourself why their opinions or attacks are bothering you. On a macro level, the issue isn't really the toxic person, the issue is the unhealed part of yourself that they keep poking at. There are other people who could deal with the exact same person and situation and not be affected, which can give you faith that it is possible to overcome these triggers. There is a quote by Shantideva that says, “Where would I find enough leather to cover the entire surface of the earth? But with leather soles beneath my feet, it’s as if the whole world has been covered.” In other words, when you overcome your triggers, all people lose the ability to be toxic to you because they are no longer bumping up against an unhealed wound.