Toxic friends are part of most social networks. One could argue that around 20% of the people you meet will have toxic and negative personalities. Because of how they feel about themselves they are willing to cause problems whenever their fragile sense of self feels damaged or they are frustrated in obtaining something they want. It is important to know when you can work these things out and when you can't.
Lets first look at the fragile sense of self. They are toxic because they have deep seated negative images of themselves and learned maladaptive methods of influence their environment. Instead of confidence and being honest with others they seek to use manipulation to gain a feeling of safety and control over their environment.
Because their thought patterns are warped it can be very hard for them to see that their behavior is inappropriate. While they may know this on one level they do not understand how they are counter to them achieving their long-term goals. As new information is presented, they anchor it with the past and the darker pain they feel pushing them to act in certain ways.
The best way to counter toxic people is to not allow yourself to be easily manipulated. Ask questions, be friendly, but make sure you have appropriate boundaries. It is difficult to manipulate someone who is confident and able to think critically about information presented to them. They can put wider information into context.
You may consider giving them a chance to recant and fix the problems they created. This would mean they have the insight into their behavior so there is some "hope" they can actually adjust their behavior for the future. If approached in a empathetic way and they still lash out it is important to start distancing yourself from the person and their behavior.
Start with first letting them know that what they are doing is not conducive to strong friendships. Each time they act inappropriately let them know it isn't appreciated and distance yourself further. If they have a shred of decency in them they will get the picture and make effort to change their behavior or risk loosing a friend. If they do not, eventually the distance will be wide enough that you can simply cut contact.
No one deserves to be treated poorly. That is not something most toxic people think about. They are not concerned with how others feel but more with how they feel and interpret information. Unfortunately, they may be acting opposite to what they want in an effort to convince themselves they don't want it in order to deaden the pain of failure. Everyone deserves a chance but if they fail in correcting their behavior you deserve a chance to surround yourself by healthy and happy people.