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.