In the body we have something called the sensory nervous system. This consists of sensory nerve fibers that passes from the sensory cells through the spinal cord to the brain. Via skin stimulation, the nervous system is affected by nerve impulses from the skin either via our pain and temperature pulses (spinotalamics) or pressure and contact pulses ( Peripheral nervous system) to the brain. Before the nerve impulses reach the cerebral cortex, they are switched to the spinal cord and then into the thalamus, using transmitter substitutions. They are divided into A-beta myelinated fibers that lead to pressure, touch and vibration, A-delta fibers that lead to strong pain and temperature. Un-myelinated C fibers cause aching pain, heat and itches.
What does this have to do with massage? Well, massage is thought to inhibit the transmission of C-fiber pulses and thus relieve pain. When stimulating the skin through massage, pressure and contact receptors are activated which emit pulses. These include bodily endorphins as transmitter substances, which inhibit pain pulses in the spinal cord lanes. Pain relief is also due to the massage's ability to increase blood circulation in the skin and reduce muscle tension.