Endorphins (or 'endogenous opiates') are natural opiate-like substances, similar to morphine and heroin, but not as potent. They are manufactured by our bodies in the presence of pain and act as a natural analgesic. There is some evidence to suggest that the pregnant woman's body starts to produce more endorphins just prior to labour.
When we feel a certain level of pain, nerve fibres coming from the brain and down the spinal cord, release endorphins. The endorphins affect the sensory nerves that carry any 'pain messages' from our body to the spinal cord (to eventually go up to the brain). This local release of endorphins stops some of the pain messages reaching the brain, decreasing the person's sense of discomfort. Endorphins are the main reason that women in strong labour look 'sleepy' and tired. It is part of their body's natural way to deal with the labour.
For many women, endorphins will also positively alter the memory of their birth experience and in some cases induce an amnesic effect (forgetting the pain). Endorphins can therefore have the potential to strengthen the woman's psyche and provide an internal 'protection' against the intensity of labour and giving birth.
The gate control theory
The 'Gate Control Theory' was first proposed by Melzack and Wall in 1965. They have since refined their theory (in 1988) and it remains one of the most respected understandings of one way our bodies can diminish the perception of pain.
The gate control theory is based on the fact that when the larger A - b (beta) skin nerves (that sense touch, heat, cold and pressure) are stimulated, they are capable of overriding the smaller A - d (delta) and C nerve fibres that sense the sharp, burning or aching pains. The larger nerve fibres carry the 'sensory message' to the spinal cord more rapidly and get priority, shutting 'the gate' as it were, to the pain messages being carried by the smaller fibres.