Hugging a hot-water bottle can have a similar effect to a painkiller by effectively "deactivating" pain at a molecular level, scientists say.
Heat has long been used as a way of relieving period pain
Researchers from University College London used DNA technology to monitor heat and pain receptors within cells.
They say temperatures over 40C (104F) switch on internal heat receptors which block the effect of chemical messengers that cause the body to detect pain.
Their research was presented to the Physiological Society conference.
The researchers wanted to look at why heat relieved internal pain such as period cramps and colic.
They used DNA technology to make both heat and pain receptor proteins in the same cell and watching the molecular interactions between the heat receptor TRPV1 and the P2X3 pain receptor.
The team found that the heat receptor can block the pain receptor.
This pain message is activated by ATP when it is released from damaged and dying cells.
By blocking the pain receptors, TRPV1 is able to stop the pain being sensed by the body.
Dr Brian King, of UCL Department of Physiology, who led the research said the molecular data showed heat could relieve pain for up to an hour.
"The pain of colic, cystitis and period pain is caused by a temporary reduction in blood flow to or over-distension of hollow organs such as the bowel or uterus, causing local tissue damage and activating pain receptors.
"The heat doesn't just provide comfort and have a placebo effect.
"It actually deactivates the pain at a molecular level in much the same way as pharmaceutical painkillers work.
"We have discovered how this molecular process works."
He said people would not choose drugs over heat for short-term pain relief.
But Dr King added that the findings could help develop better pain relief medication in the future.
"The focus of future research will continue to be the discovery and development of pain relief drugs that will block these P2X3 pain receptors.
"Our research adds to a body of work showing that P2X3 receptors are key to the development of drugs that will alleviate debilitating internal pain."
Dr Liz Bell, of the Physiological Society, said: "It was thought heat just had the general comfort factor, or an effect on blood circulation.
"But this research gives an insight into how heat actually works.
"It will be important in developing a better generation of effective pain-killing drugs."