Go ahead, enjoy that morning mug. A new study suggests that people who are in the habit of drinking coffee regularly may be protected against malignant melanoma, the leading cause of skin-cancer death in the United States.

People in the study who drank four or more cups of coffee daily were 20 percent less likely to develop malignant melanoma than noncoffee drinkers, according to the study published today (Jan. 20) in JNCI: Journal of the National Cancer Institute.

Of course, the findings don't give you license to fire up the Mr. Coffee and then spend your day lounging in the sun without any sunscreen — the best way to prevent skin cancer remains avoiding sun exposure and ultraviolet radiation, said study researcher Erikka Loftfield, a doctoral student at the Yale School of Public Health and a fellow at the National Cancer Institute.

"Our results, and some from other recent studies, should provide reassurance to coffee consumers that drinking coffee is not a risky thing to do," Loftfield told Live Science in an email. "However, our results do not indicate that individuals should alter their coffee intake." [Top 10 Anti-Cancer Foods]

Measuring java's effect

Previous studies had found hints that drinking coffee might be linked to lower rates of nonmelanoma skin cancers, but the findings were mixed when researchers looked at coffee and melanoma, the deadliest form of skin cancer. Melanomas arise from pigment cells in the skin called melanocytes. According to the National Cancer Institute, 76,100 new cases were diagnosed in the United States in 2014, and 9,710 people died of the disease.

Loftfield and her team pulled data from a huge study run jointly by the National Institutes of Health and the American Association of Retired Persons, which tracked 447,357 retirees over 10 years, on average. Ultimately, in this group, there were 2,904 cases of malignant melanoma (a cancer that has spread beyond the top layer of the skin), and 1,874 cases of early-stage melanoma, which remains only on the top layer of the skin.

"Our study is the largest to date to evaluate this relationship" between melanoma and coffee drinking, Loftfield said.

The participants reported their coffee consumption as well as other factors that might influence their cancer risk, including exercise, alcohol intake and body-mass index. To estimate people's UV exposure, the researchers used NASA data on the amount of sunlight in each participant's hometown.

Perky protection?

After the researchers controlled for the other factors, coffee drinking turned out to be a boon: There were 55.9 cases of melanoma yearly per 100,000 people among those who drank at least four cups a day, versus 77.64 cases yearly per 100,000 people among the people who didn’t drink coffee, the researchers wrote.

The findings specifically applied to caffeinated coffee, not decaf. It's possible that caffeine itself could be the protective factor, but there could also be some other compound in coffee that protects against malignant melanoma that is more abundant in caffeinated coffee than in the decaffeinated variety, the researchers said.

The lack of a link with decaf could be due to chance, Loftfield noted.

The researchers plan to look for evidence of this protective effect in other groups of people, but Loftfield warns that the research is limited: The scientists had no way of knowing about the sunscreen habits of their respondents, or their skin coloring (lighter-pigmented and freckled people are more prone to melanoma). Nor is it clear what coffee contains that could help save the skin.

Follow Stephanie Pappas on Twitter and Google+. Follow us @livescience, Facebook & Google+. Original article on Live Science.