The primary cause of melanoma is ultraviolet (UV) radiation from the sun or tanning beds, which can damage the DNA in skin cells. Factors that increase the risk include having fair skin, a history of sunburns, excessive UV exposure, a large number of moles, and a family history of melanoma. Genetic mutations and immune system deficiencies can also play a role.