In addition, further evidence of the association emerged when the same tests were carried out on 921 teenagers, who were taking part in an Australian twin study.
The nature of the relationship between autism and intelligence is not clear, said the researchers.
Although up to 70 per cent of people with autism have a mental disability, some individuals with the disorder can exhibit higher than average non-verbal intelligence.
This form of intelligence allows complex problems to be solved using reasoning skills requiring little or no use of language, which is impaired in people with autism.
Dr Toni-Kim Clarke, of the University of Edinburgh's Division of Psychiatry, who led the study, said: :Our findings show that genetic variation which increases risk for autism is associated with better cognitive ability in non-autistic individuals.
"As we begin to understand how genetic variants associated with autism impact brain function, we may begin to further understand the nature of autistic intelligence."
Co-author Professor Nick Martin, from the Queensland Institute for Medical Research, said: 'Links between autism and better cognitive function have been suspected and are widely implied by the well-known Silicon Valley syndrome and films such as Rain Man as well as in popular literature.
"This study suggests genes for autism may actually confer, on average, a small intellectual advantage in those who carry them, provided they are not affected by autism."
The findings appear in the journal Molecular Psychiatry.
Genetics 'are to blame for nearly all autism cases'
Autism is almost always caused by a child's genes, a major study of British twins has found.
Scientists said that genes are responsible for as many as 98 per cent of cases - a higher proportion than previously thought.
The research, by King's College London, also found the condition is highly inheritable.
Controversial research linking autism with the MMR jab has been widely discredited, but more recent concern has focused on the condition being fuelled by environmental factors such as pollution.
With cases of autism much more common today than in the past, many fear it is also being caused by modern lifestyles.
Estimates suggest that as many as one in 100 people in the UK now has autism.
But the researchers said their study suggested that lifestyle and environmental factors were a distant second to genetics.
The team compared the behaviour of pairs of identical twins, who share all their DNA, and non-identical twins, who have only half their genes in common.
They found the condition was far more common in identical twins than in non-identical ones. The study, in the journal JAMA Psychiatry, concluded that DNA was behind between 74 to 98 per cent of autism cases.
If genes are key, the recent rise in cases could be explained by more people being correctly diagnosed with the condition.
Dr Francesca Happe told the BBC: "Our findings suggest environmental factors are smaller, which is important because some parents are concerned whether things like high pollution might be causing autism. The main consensus now is that the rise in diagnosis has more to do with increased awareness of the condition."
Dr Judith Brown, of the National Autistic Society, said: "Autism is a highly complex story of genes not only interacting with other genes, but with non-genetic factors too.
"This large population-based twin sample is significant because it helps us to understand much more about the role genetics play in autism and opens up the possibility of whole families gaining a better understanding of a condition they may share."
But she added: "We are still a long way from knowing what leads to autism.
"What people with the condition, their families and carers need most of all is access now to the right kind of support to be able to lead full lives."
- Daily Mail