Evolutionary biologists have traced the origins of masturbation to pre-ancient primates 40 million years ago.
According to new research, self-pleasuring served as an ‘evolutionary purpose’ as it protected men against sexually transmitted diseases and boosted their fertility.
Female masturbation boosts libido and soothes period cramps, according to the scientists.
The study found primates masturbated more than other members of the animal kingdom and it is an older practice than previously believed.
"Our findings help shed light on a very common, but little understood, sexual behaviour and represent a significant advance in our understanding of the functions of masturbation,” Dr Matilda Brindle, lead author of the University College London study, said.
They support the idea it increases reproductive success and protects against STIs.
Dr Brindle said: "Historically, masturbation was considered to be either pathological or a by-product of sexual arousal.
"Recorded observations were too fragmented to understand its distribution, evolutionary history or adaptive significance.
"Perhaps surprisingly, it seems to serve an evolutionary purpose."
Her team collected the largest ever dataset on masturbation, pooling information from nearly 400 sources.
They included 246 published academic papers and 150 questionnaires and personal communications from primatologists and zookeepers.
It enabled the British team to track the distribution of onanism across primates - identifying when and why it evolved in both females and males.
Dr Brindle said: "We find support for two potential adaptive functions of masturbation in male primates, suggesting it may increase reproductive success and reduce the chance of contracting STIs by cleansing the genital tract."
Previous research has suggested masturbating more makes men better lovers and boosts their orgasms.
It has also been shown to relieve stress and flush out potentially cancerous prostate cells.
Female masturbation is said to improve mood and libido and sooth period cramps.
Dr Brindle said: "Masturbation has a long evolutionary history amongst primates.
"It was most likely present in the common ancestor of all monkeys and apes - including humans."
Much remains unknown about it - popularly dubbed ‘the missing link.’ Recent evidence suggests it resembled a gibbon - but a definitive fossil is yet to be unearthed.
Less clear is whether the ancestor of the other primates - lemurs, lorises and tarsiers - masturbated because data were more scarce for these groups.
The researchers tested several theories including the ‘postcopulatory selection hypothesis’ which proposes masturbation aids successful fertilisation.
Dr Brindle said: "This can be achieved in various ways. First, masturbation without ejaculation can increase arousal before sex.
"This may be a particularly useful tactic for low-ranking males likely to be interrupted during copulation, by helping them to ejaculate faster.
"Second, masturbation with ejaculation allows males to shed inferior semen - leaving fresh, high-quality sperm available for mating, which are more likely to outcompete those of other males."
Indeed, the study showed male masturbation has co-evolved with multi-male mating systems where competition is high.
The ‘pathogen avoidance hypothesis’ also suggests male masturbation protects against catching an STI after copulation.
It washes out the urethra, a tube leading to the bladder which is a primary site of infection.
Dr Brindle said: "Male masturbation co-evolved with high STI load across the primate tree of life."
But the significance of female masturbation remains more of a mystery. While frequent, there are fewer reports describing it.
Dr Brindle said: "More data on female sexual behaviour are needed to better understand the evolutionary role of masturbation."
She added: "The fact autosexual behaviour may serve an adaptive function, is ubiquitous throughout the primate order, and is practised by captive and wild-living members of both sexes, demonstrates masturbation is part of a repertoire of healthy sexual behaviours."
The study was published in Proceedings of the Royal Society B Biological Sciences.
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies