When it's very very bad, get into a cold shower immediately (clothes and all, because I cannot stand my body) with my face in the shower stream. I tell myself that if I still want to harm after I'm in a cold shower for 10 whole minutes, then I can. (I set my phone as a timer)
These work on two levels. One - I hate the cold shower. Sometimes the sheer hatred of the cold shower will stop me. And even if I make it into the shower - 10 minutes is a long time. I've never made it 10 minutes. By the time I get past 5, my internal panic has calmed down, and I can access some other coping strategies.
When I'm just dealing with smaller urges, things that don't consume my whole self, I can plunge my face into a bowl of ice water (kept in the fridge for that purpose). Both of these techniques trigger a phenomenon called the mammalian diving reflex/response. It's a pretty cool thing that mammals do. For humans, it's not activated unless the water is on the face. Some people can activate it just with a cold washcloth (very cold) applied to the top half of the face (forehead, nose, sinus region).
Here's a nice link about it:
The Diving Reflex - Breatheology
After I've done the cold water routine, I move on to a list of very simple distractions that I have written out. I just do one, again setting the timer for 5 minutes. If at the end of 5 minutes it's not helping me and my mind is wandering back to self-harm, I go to the next distraction. Repeat until I have become engaged in something, and then just do it for a bit. If I need to restart the whole process, I do.
It's kind of intricate, I guess - but after about a year of trial and error, this just became the method for me.