Stimuli which cause pain are picked up by nociceptors and converted into nerve impulses which travel to the brain. Imagine stepping on a sharp object whilst barefoot. Nociceptors in the skin trigger a series of events which are perceived as pain in the brain:
Pain information in the form of nerve impulses is carried from your foot to the spinal cord and from here it is relayed to the brain. Pain can be modified or modulated in the spinal cord. This means that pain can be enhanced or lessened or blocked completely. This modulation takes place in the dorsal horn of the spinal cord.
The neurones which carry pain information from your foot to the brain make up a pain pathway
(see diagram1). There are several pain pathways, the lateral spinothalamic tract is an important pain pathway. This pain pathway carries information from the periphery ie. the foot in this case, up the leg to the spinal cord and from here to the thalamus, hence spinothalamic tract. From the thalamus the pain information is carried or projected to the cerebral cortex.
In diagram 1, the pain information enters the dorsal horn of the spinal cord and synapses with a second neurone which carries the information up the spinal cord. The synapse shown on the diagram is situated in an area of the grey matter of the spinal cord called the substantia gelatinosa ( see diagram 2).