One quick comment in addition to the good posts here already: fear and aggression are almost always related to each other. Confident dogs are assertive, they only display as much threat as the situation requires, and sit back and assess the situation first (they ask questions first, and attack later if warranted). Fearful dogs are often quick to display threat (which is what it sounds like your dog did), since they lack the confidence to both wait and see what happens, and in their ability to handle whatever DOES happen (they attack first and ask questions later). I suggest you read
this excellent post from Mick Trainer about nerve.