Scientists say they now know why around a quarter of people with HIV develop dementia.
The link with dementia has been hard to uncover
The team at Thomas Jefferson University, Philadelphia, said the virus produces proteins that cause brain cells to die.
The finding, published in the Proceedings of the National Academy of Sciences, comes after two decades of research.
The National Aids Trust said the breakthrough would help patients.
The reason for HIV leading to dementia has puzzled scientists because, unlike other brain infections such as meningitis and herpes, HIV causes hardly any brain inflammation or white blood cell increase.
HIV causes neurons - or nerve cells - to die, leading to wastage of the brain.
This is "extremely unusual" and different to other infectious agents, according to Dr Roger Pomerantz, at Jefferson Medical College.
The theory has previously been that HIV infects brain cells called macrophages and miroglia, which then produce cytokines and chemokines, killing neurons.
Dr Pomerantz's team tested whether the virus itself caused the nerve cells to die, or whether this was caused by substances produced by infected cells.
They looked at brain cells and T-lymphocyte blood cells, taking the virus out of some of them and leaving it in others.
When applied to the nerve cells, they found they were killed when the virus and its proteins were present.
Dr Pomerantz added: "When we looked at T-cells, the only thing that killed neurons was the virus.
"Once the virus is removed, nothing from the T-cells would kill neurons."
Further experiments, called microarray technology, established that levels of cytokines and chemokines were low and unlikely to be the cause of the brain disease.
And, after investigating the neurons themselves, they found two well-defined pathways to cell death, which were activated by proteins from the virus.
Dr Pomerantz said: "We feel that it is mainly the virus and viral proteins causing the neuronal cell death, and may now know the precise pathways involved."
This would allow the development of treatments which prevent the virus damaging the neurons, he said.
The National Aids Trust welcomed the research.
David Coulthread, its director of policy and campaigns, said: "There has previously been no clear link, so this kind of information adds to the sum of the knowledge we have about HIV and the way it affects the human body."
Patients taking the HAART cocktail of retroviral drugs are less likely to develop dementia than those who do not take the treatment.
Given this, he said the finding "reinforces the need to come forward for early diagnosis".
Spotting the virus early allowed patients to be given the anti-retroviral drugs which prevent the development of dementia, and this would save the NHS money in the long run, he said.