They also found the gene that causes hair to curl
Scientists have identified the gene for grey hair - confirming that turning grey with age is partly determined from birth.
The discovery means further research could pave the way to treatments that delay, halt or reverse the process.
The IRF4 gene was identified as the culprit by a team which analysed DNA samples from 6,357 men and women of mixed ethnic ancestry from five South American countries.
They also found the PRSS53 gene causes hair to curl, EDAR determines beard thickness and hair shape, FOXL2 for eyebrow thickness, and PAX3 which influences the likelihood of growing a monobrow.
A "new" variant of the PRSS53 gene was found to be linked to very straight hair.
The IRF4 gene was already known to play a role in hair, skin and eye colour.
Hair greying is caused by an absence of the pigment melanin. Its production and storage is regulated by a process involving IRF4.
Study leader Professor Andres Ruiz-Linares, from University College London, said: "We have found the first genetic association to hair greying, which could provide a good model to understand aspects of the biology of human ageing".
"Understanding the mechanism of the IRF4 greying association could also be relevant for developing ways to delay hair greying".
Researcher Dr Kaustubh Adhikari said the breakthrough was only possible "because we analysed a diverse melting pot of people, which hasn't been done before on this scale".
The team believes the genes are unlikely to work in isolation to cause greying or straight hair, but have a role to play along with other factors yet to be identified.
Their findings are reported in the journal Nature Communications.