Its your sympathetic nervous system activating your fight or flight response. Since the stimulus is an outside effect, it is a signal sent by your cortex (brain) to the ventral-medial hypothalamus (the VMH is the crown of the sympathetic nervous system). The VMH sends a signal to your adrenal cortex which releases a hormone (Epinephrine - EPI or Adrenline) in your bloodstream that acts on the beta-neuroreceptors on your liver (i think, its been a year since I learned this). The signal caused by EPI changes a lot of your normal functions including an increased heartrate, release of urine, dry mouth, active thoughts, vasoconstriction (constriction of the blood vessels - helps during hemmorhaging), a decrease in insulin release (allowing for the release of nutrients in your body), etc. This signal is not just cognitive (caused by the brain), it can also be elicited by things such as pain, hemmorhage, low blood pressure, etc.
If you really wanna know more, get at me and I can look through my neuroscience books. I used to know this shit like the back of my hand.
The signal is usually caused by a perceived threat or nervousness (aka an impending fight, a test, job interview, etc.) You can learn to control this by understanding how your body reacts to these threats and finding a different method of reacting to it. When I took karate, I used to get hella nervous before a sparring match or tournament, and I'd start shaking and I'd have to pee and stuff, but its bad because you have active thoughts, and its hard to remain calm and make wise decisions. After about 2 years of sparring, I was in a completely calm state before the fight started. My opponent would have some crazy adrenaline rush and would just start throwing punches and acting all crazy. I'd just stand there, completely calm, no adrenaline rush, and I would have the upper hand. After learning how to control my adrenaline, I started placing first in sparring tournaments (I wasn't good at forms or weapon techniques, but I was nasty at sparring and board breaking, something I attribute to having a lot of focus). Its basically the difference between fighting with your head and fighting with your heart. Your heart can really lead you astray.