Things that may not have been mentioned:
First, and that's the most important - you need to talk frankly to your friend about what happen - both so your son realises how important and hurtful his behavior was (if it's covered up he'll see no reason not to do it again, as long as he covers it up), and so you're friend's daughter get the help she needs. She doesn't just need conforting, she also need to be reinforced to the idea that noone is allowed to threaten her, even another kid, even a friend. Especially because she's a girl.
If you explain to your friends what you're going to do to help your son, that would make it easier for her to overlook the incident (not forgeting - your kid needs to know he can't threaten somebody and see them act all nice and trusty towards him later).
As for your son, apart for clearly making him understand that such an attitude is unacceptable under any circumstances - even if he's angry, even if the other person has insulted him or hurt him, even if he doesn't have a farther - listening to what he has to say can help him understand he's not rejected, only his conduct is. Then have a good talk about why threats, physical or not, are wrong, and why physical violence is to be banished. Talk about the consequences in society of his conduct - even if he's a kid. Talk about the consequences for him, the kind of person he wants to become.
You can't do that if you're to emotional about it, so you need to stop asking yourself what you did wrong. Plenty of kids raised by disfunctional couples and abusive parents still grow up to be stable adults, what your kid did is not justified by anything in your eductation. Don't enter a debate if your kid tries to manipulate you by guilting you - listen tohim, take note of the few points he could be right (times like those are a good way to see what's weighting on your kid's heart), but don't let them guilt you. Nothing, even abuse, excuses his behavior, if it was the case we'd loose half the kids population every year.
Talk to your family doctor about it, get his recommandations for a good kid psychologist, see the psychologist by yourself and determine with him if it would be a good idea for your kid to see one (don't suggest to your kid he might need to see a psychologist then not have him see one, be sure before you talk to him about it). See with your kids when he has felt like this before (don't say 'menace someone'), assess the extent of the problem. Many of us has behaved badly at least once as kids, and it's not the end of the world, it's just that this event is a serious one.
On the long term:
Kids that read a lot have a far lower tendency to result to violence, because the inability to verbalise long sentences and complex ideas in your head means you only have violence to resort to when solving conflicts.
Martial art classes are really good for a kid's self-esteem and respect of other people's self integrity - judo is really fun for kids, very good to release tensions. Better than other arts like karate, because judo relies not on punches and kicks, but on grappling, and that demands a tremendous amount of energy, especially on the ground, which is what beginners learn first - all the fun of wrestling, without the silly tights that flash your nuts to all your classmates. If you can't because you're still a Witness or your kid still half believes it, any sport is good, check what your kid would like to do. It's the end of the school year, all clubs (city or school) are happy to see prospective members checking them in advance, instead of having kids start in september and realise they don't like the sport a few days later. There's probably open days and demonstrations to, see with your city's sports service. It's really worth the investment, even for yourself if you're a single mother. Happier, more confortable and at peace mom = heaven as a kid in a monoparental family.
Can't vouch for it myself though, our mom never wanted to take herself in charge and we had to be the adults, which is the worst thing you can ask of a kid. So you can see that on the parenting scale you can't be doing that bad, can you?
PS: (humor) "where have I gone wrong as a mother?" I'd usually start with the cult, but that might not be relevant ;)