Sun exposure is critical for the body's production of vitamin D, which keeps bones, teeth, and muscles healthy.
Certain genes can determine which people are more at risk of getting sunburnt, and possibly develop skin cancer as a result, scientists say.
In a trawl of the genetics of nearly 180,000 people of European ancestry in Britain, Australia, the Netherlands and United States, researchers found 20 sunburn genes.
Eight of the genes had been associated with skin cancer in previous research, according to findings published in the journal Nature Communications.
And in at least one region of the genome, "we have found evidence to suggest that the gene involved in melanoma risk... acts through increasing susceptibility to sunburns," co-author Mario Falchi of King's College London told AFP.
Sun exposure is critical for the body's production of vitamin D, which keeps bones, teeth, and muscles healthy, and which scientists say may help stave off chronic diseases, even cancer.
But too much can be painful in the short-term, and dangerous for your health.
The new study, which claims to be the largest to date into the genetics of sunburn, helps explain why people with the same skin tone can have such different reactions to exposure to sunlight -- some burn red while others tan brown.
It may also begin to explain factors in skin cancer risk.
"It is necessary to explore these genes in more detail, to understand the mechanism by which they contribute to propensity to burn," said Falchi.
In future, the research may help identify people at risk, through genetic testing.
"People tend to 'forget' that sunburns are quite dangerous," said Falchi.
"Given the rise in incidence in skin cancer, we hope that knowing there is a genetic link between sunburn and skin cancer may help in encouraging people to lead a healthy lifestyle."