Tiny changes to an "alarm" protein which responds to infections may explain why some with HIV can control their condition without drugs.
Around one in 300 people with HIV are "controllers", and scientists want to replicate how their bodies behave.
Writing in Science, US researchers say differences in five amino acids in a protein called HLA-B are key.
But a UK expert said there was still a "long way" to go before a vaccine or a new drug for HIV could be developed.
HIV "controllers" were first identified almost 20 years ago. They are able to suppress viral replication with their immune system, keeping viral load at extremely low levels, without using anti-retroviral drugs.
It was already known that certain genes involved with the HLA system were important for HIV control. But scientists had not identified which genes were involved or how they acted.
Drag and drop
The researchers carried out a genome-wide association study of the genetic make-up of almost 1,000 controllers and 2,600 people with progressive HIV.
Around 300 points were found to be associated with immune control of HIV, all in regions of chromosome six that code for HLA proteins.
Scientists were then able to pinpoint specific amino acids and identified the five in the HLA-B protein as playing the key role.
HLA-B is part of the process by which the immune system recognises and destroys virus-infected cells.
Part of the protein called a binding pocket "drags and drops" peptides from inside the virus onto the cell membrane.
These then mark out the cell for destruction by CD8 "killer" T cells in the immune system.
All five of the amino acids identified by researchers are in the binding pocket.
Scientists from Massachusetts General Hospital, Massachusetts Institute of Technology and Harvard University carried out the work.
Bruce Walker of the Ragon Institute at Massachusetts General Hospital, one of the lead authors of the paper, said: "We found that, of the 3bn nucleotides in the human genome, just a handful make the difference between those who can stay healthy in spite of HIV infection and those who, without treatment, will develop Aids.
"Knowing how an effective immune response against HIV is generated is an important step toward replicating that response with a vaccine.
"We have a long way to go before translating this into a treatment for infected patients and a vaccine to prevent infection, but we are an important step closer."
Gus Cairns, editor of HIV Treatment Update of the UK's National Aids Manual, said: "As the researchers say, this research opens the door to the development of a vaccine that could encourage the body to mimic the most effective kind of immune response, or to drugs that could interfere with HIV's ability to infect cells and derange the immune system.
"Nonetheless there is still a lot we don't know about why some genetic variants provide a much less welcoming environment for HIV than others and, although we are becoming clearer about what kinds of specific immune response are effective against HIV, we are a long way from being able to make them happen, or even knowing what we must do to make them happen."