The question then becomes “OK, I understand that pain is an output, and is influenced by all these different factors separate to the signals coming form the body. But what can I do about my chronic pain??”
One common metaphor that seems to be helpful for a lot of people is the idea of a fuse.
When something happens in the body, like twisting your ankle, information about the potential damage (stretch or compression in the tissues etc) travels up the nerve.
We can visualise this like a fuse burning in a cartoon.
When it gets to the spinal cord, it has to ‘jump’ a little gap, called a synapse, before continuing up the spinal cord to the brain. Various factors can affect the strength of these signals.
Some, like endorphins (chemicals that reduce pain and stress), adrenaline (I think everyone’s heard of that one!) and cortisol (the ‘stress hormone’, which can intensify the pain experience,,), are neurotransmitters or hormones, chemicals that interact with receptors in different area of the body to change the way things work.
Going back to our fuse metaphor, we can think of the inhibitory factors as buckets of water.
Imagine what happens when we throw two hundred-odd buckets of water on some little fuse… That’s right! It goes out. We don’t feel any pain.
This is often what happens when we get injured while playing sports: because there is a big surge of adrenaline, it hurts a lot less than it does, say, five or six hours later.
Pain is the label your body attaches to something when it feels it has more [credible] evidence of threat, than of safety.
If you have more buckets of water than petrol, no pain; and vice versa.
Well, except that your brain is inside your head (it would be worrying were it not). Dammit, you know what I mean.
It stands to reason, then, that if we change the ways we think and feel about our pain, the way we feel the pain will also change!
 The biochemical and neuroendocrine bases of the hyperalgesic nocebo effect.
Benedetti F, Amanzio M, Vighetti S, Asteggiano G
J Neurosci. 2006 Nov 15; 26(46):12014-22.
 Nocebo hyperalgesia: how anxiety is turned into pain.
Colloca L, Benedetti F
Curr Opin Anaesthesiol. 2007 Oct; 20(5):435-9.
 Isolating the modulatory effect of expectation on pain transmission: a functional magnetic resonance imaging study.
Keltner JR, Furst A, Fan C, Redfern R, Inglis B, Fields HL
J Neurosci. 2006 Apr 19; 26(16):4437-43.
 Wood P, Schweinhardt P, Jaeger E, et al. Fibromyalgia patients show an abnormal dopamine response to pain. Eur J Neurosci. 2007;25:3576–3582
 Baliki MN, Geha PY, Fields HL, Apkarian AV. Predicting value of pain and analgesia: nucleus accumbens response to noxious stimuli changes in the presence of chronic pain. Neuron. 2010;66:149–160.
 Baliki M, Petre B, Torbey S, et al. Corticostriatal functional connectivity predicts transition to chronic back pain. Nat Neurosci. 2012;15:1117–1119.