A discovery was made by scientists which shows for the first time how humans - and other mammals - have evolved to have intelligence.
Researchers have identified the moment in history when the genes that enabled us to think and reason evolved.
This point 500 million years ago provided our ability to learn complex skills, analyse situations and have flexibility in the way in which we think.
Professor Seth Grant, of the University of Edinburgh, who led the research, said: "One of the greatest scientific problems is to explain how intelligence and complex behaviours arose during evolution."
The research, which is detailed in two papers in Nature Neuroscience
, also shows a direct link between the evolution of behaviour and the origins of brain diseases.
Scientists believe that the same genes that improved our mental capacity are also responsible for a number of brain disorders.
"This ground breaking work has implications for how we understand the emergence of psychiatric disorders and will offer new avenues for the development of new treatments," said John Williams, Head of Neuroscience and Mental Health at the Wellcome Trust, one of the study funders.
The study shows that intelligence in humans developed as the result of an increase in the number of brain genes in our evolutionary ancestors.
The researchers suggest that a simple invertebrate animal living in the sea 500 million years ago experienced a 'genetic accident', which resulted in extra copies of these genes being made.
This animal's descendants benefited from these extra genes, leading to behaviourally sophisticated vertebrates - including humans.
The research team studied the mental abilities of mice and humans, using comparative tasks that involved identifying objects on touch-screen computers.
Researchers then combined results of these behavioural tests with information from the genetic codes of various species to work out when different behaviours evolved.
They found that higher mental functions in humans and mice were controlled by the same genes.
The study also showed that when these genes were mutated or damaged, they impaired higher mental functions.
"Our work shows that the price of higher intelligence and more complex behaviours is more mental illness," said Professor Grant.
The researchers had previously shown that more than 100 childhood and adult brain diseases are caused by gene mutations.
"We can now apply genetics and behavioural testing to help patients with these diseases", said Dr Tim Bussey from Cambridge University, which was also involved in the study.