The disease was discovered after she had several moles removed and analysed while having reconstructive surgery following a mastectomy, her spokesman revealed.
One of the moles was found to be cancerous and doctors are working to establish if it was caught early.
The duchess, 64, "remains in good spirits", despite it being "distressing" to have another cancer diagnosis.
The spokesperson went on to say that she is hoping to help raise awareness of the importance of looking out for changes in moles.
"She believes her experience underlines the importance of checking the size, shape, colour and texture and emergence of new moles that can be a sign of melanoma," the spokesperson added.
The news comes after it was revealed in July last year that chef and TV presenter James Martin also had a skin cancer diagnosis.
Also last year, broadcaster Chris Evans shared he was diagnosed with skin cancer. He shared the news with his listeners on his Virgin Radio show and said it was discovered in the early stages.
"It is a melanoma," he shared. "There's this phrase called a malignant melanoma - you know once you get something, and you find out all about it - that is a redundant phrase because if it is a melanoma it is malignant. But it's been caught so early, just so you know, that it should be completely treatable."
Evans' diagnosis came after Jeremy Hunt, 56, shared how "blessed" he felt after his own skin cancer diagnosis came early enough to be treated.
The first sign he noticed was a mole on his head that "grew and grew". Further tests showed it was basal cell carcinoma, and he had the mole removed.
Skin cancer: the facts
Cancer Research UK has warned that melanoma skin cancer incidence rates are projected to rise by 9% in the UK between 2023-2025 and 2038-2040.
There could be around 26,500 new cases of melanoma skin cancer every year in the UK by 2038-2040, projections suggest.
Worldwide Cancer Research says getting sunburnt just once every two years can triple your risk of getting skin cancer.
Melanoma is thought to be the most serious type of skin cancer, while 'non-melanoma' skin cancers include basal cell carcinoma (BCC) and squamous cell carcinoma (SCC).
Skin cancer signs and symptoms
Finding skin cancer early saves lives. FACT. "Melanoma detected and removed early is almost always curable," says consultant dermatologist Dr Anjali Mahto previously told Yahoo UK. "If caught late, there is a much higher chance of the cancer spreading to other parts of the body. The 5-year survival rate is around 95% for early, stage 1, disease compared to about 16% for late, stage 4, disease."
How to examine your moles
Most dermatologists recommend skin self-exam on a monthly basis.The acronym ABCDE can be extremely helpful in evaluating moles. If a mole shows any of these features, it warrants review by a GP or dermatologist to exclude melanoma.
Asymmetry: one half of the mole is different to the other
Border: irregular, scalloped or poorly defined edge
Colour: uneven colour or variable colours within a mole
Diameter: the mole is bigger than 6mm in size
Evolving: the mole is changing in its size, shape or colour
Other signs to look out for include any new moles, a mole that looks significantly different to the others, or any skin lesion that bleeds or fails to heal.
Read more on skin cancer
A complete guide to sun protection and SPFs, after Hugh Jackman reveals new skin cancer scare (Yahoo Life UK, 7-min read)
Fashion vlogger and skin cancer survivor urges people to be careful in the sun (The Argus, 3-min read)
How bad is a sun tan, really? (The New York Times, 4-min read)
Different types of skin cancer
1. Basal cell carcinoma
BCC starts in the cells lining the bottom of the epidermis (outer layer of skin) and accounts for about 75 in every 100 skin cancers, according to the NHS.
Key features include:
red spots or marks that persist for months (whereas an acne spot or infected hair follicle usually goes away within a month), very gradually enlarging
sometimes, they bleeds intermittently, or the skin breaks to form a sore that is not healing
2. Squamous cell carcinoma
SCC starts in the cells lining the top of the epidermis and accounts for about 20 in every 100 skin cancers.
"This type of skin cancer is related to excessive sun exposure, it can spread to local lymph nodes. Look out for a rapidly growing red spot, which usually has some crusts on the surface, can bleed and become painful,” Dr Nicole Chiang, consultant dermatologist previously told Yahoo UK.
Melanoma can arise from an existing mole, or come from a completely new mole.
While exposure to the sun’s harmful ultraviolet (UV) rays is a leading cause of skin cancer, you’re not necessarily risk-free if you don't sunbathe or use sun beds.
Skin cancer risk factors
Sunburn: We all know it, burning is bad when it comes to skin cancer, but according to Dr Mahto, a person’s risk of melanoma doubles if they have had more than five sunburns
Outdoor hobbies and occupation
Tanning bed use
Family history of melanoma: Approximately 10% of people with melanoma will have a family member with the disease
Lots of moles
Immunosuppression: "Often forgotten about, but a compromised immune systems as a result of chemotherapy, organ transplant, lymphoma or HIV/AIDS can increase the risk of melanoma," Dr Mahto explains
How to reduce your skin cancer risk
Dr Mervyn Patterson, from Woodford Medical has put together some sun-safe tips
Sunscreen – this should be broad spectrum containing protection against UVA and UVB and a factor of at least 15-30 should be recommended. This needs to be applied at least 30 minutes before going outdoors and reapplied every 2 hours for maximum benefit
Seek shade particularly between 11am to 4pm
Wear a wide-brimmed hat and sunglasses
Wear protective loose cotton clothing over the arms and legs
Try not to use tanning beds
See a GP as soon as possible if you notice any changes in your moles or freckles or have any skin abnormality. While it is unlikely to be cancer, it is always worth getting checked early.