Common painkillers such as aspirin and ibuprofen may be tied with a lower risk of skin cancer, according to a new study.

Danish researchers analyzed medical records from northern Denmark over a period of nearly two decades and found people who regularly took aspirin or other non-steroidal anti-inflammatory drugs (NSAIDs) – especially at high doses – had a significantly lower risk of developing skin cancer over time, regardless of age or gender.

“Previous studies suggest that NSAIDs decrease the risk of some cancer types, especially colorectal cancer,” lead researcher Sigrún Alba Jóhannesdóttir, BSc, at the Department of Clinical Epidemiology, Aarhus University Hospital in Denmark told FoxNews.com.  “Also, some studies exist on the association between NSAIDs and skin cancer in specific, and they largely support a protective effect.”

“Our study had advantages in the methods used compared with previous studies,” Jóhannesdóttir added. “We were able to investigate various types and patterns of NSAID use in the general population, we used validated registry data, and we used reliable prescription data collected before cancer diagnosis instead of relying on patients recalling their use.”

The study focused on the three major types of skin cancer: basal cell carcinoma, squamous cell carcinoma and malignant melanoma.

Approximately 13,000 cases of basal cell carcinoma, 2,000 cases of squamous cell carcinoma, and 3,200 cases of malignant melanoma were identified in the study, which were then compared to information, including prescription data, from approximately 179,000 patients who did not develop skin cancer.

Patients who had more than two prescriptions for NSAIDs appeared to have a 15 percent decreased risk of developing squamous cell carcinoma and a 13 percent decreased risk of developing malignant melanoma than those who had fewer or no prescriptions for the medications.

The effect was particularly strong among patients who took NSAIDs for seven or more years at ‘high intensity.’

“We were not able to determine the minimal daily or weekly doses needed,” Jóhannesdóttir said. “However, we did find that the protective effect was greatest when used frequently and over a long time period (over 7 years). Other studies need to investigate details of minimal dose and length of treatment.”

While the results did not indicate there was a general reduced risk of developing basal cell carcinoma among NSAID users, there was evidence that these individuals did have a 15 percent and 21 percent reduced risk of developing the cancer on less-exposed areas of the body (other than the head and neck) if they took the pills over a long period of time or at a high intensity, respectively.

According to Jóhannesdóttir, NSAIDs may exhibit these protective effects because the medications work by inhibiting specific enzymes involved in inflammation (COX enzymes).

“Previous studies show that elevated levels of these enzymes are found in skin cancer and that they are involved in important steps of cancer development such as inhibition of cell death, suppression of the immune system, and stimulation of angiogenesis and invasiveness,” she said.

The difference for basal cell carcinoma patients may be explained by dissimilarities in the expression of COX enzymes.  In addition, some NSAIDs can actually increase sensitivity to the sun.

“It is possible that this adverse effect or sun exposure itself outweighs the beneficial effects of NSAIDs at some sites and for some cancers,” Jóhannesdóttir said. “However, we could not examine the molecular mechanism behind our results.”

However, while NSAIDs may be protective against skin cancer, it is important to note that the medications do come with certain risks that may need to be weighed against the potential benefits.  Prolonged usage of NSAIDs has been associated with side effects such as kidney damage, stomach problems and excessive bleeding.

“Because there are also risks associated with the use of NSAIDs, we cannot give recommendations on NSAID use in general. As with all types of drugs, it is up to the patient and his or her physicians to balance benefits and harms,” Jóhannesdóttir said, adding that other studies need to look further into the association between NSAIDs and reduced skin cancer risk.

“We hope that our findings will inspire more research within this field,” she said. “Meanwhile, we want to stress that sun protection remains the most important prevention against skin cancer.”

The study was published in CANCER, a journal of the American Cancer Society.