Cutaneous melanoma (CM) is the most lethal form of skin cancer. Risk assessment should facilitate stratified surveillance and guide treatment selection. Here, based on the mRNA-seq data from 419 CM patients in the Cancer Genome Atlas (TCGA), we developed a prognostic 21-gene signature to distinguish the outcomes of high- and low-risk patients, which was further validated in two external cohorts. The signature achieved a higher C-index as compared with other known biomarkers and clinical characteristics in both the TCGA and validation cohorts. Notably, in high-risk patients the expression levels of three driver genes, BRAF, NRAS, and NF1 in the MAPK pathway, were lower but exhibited a stronger positive correlation as compared with low-risk patients. Moreover, the genes involved in nicotinamide adenine dinucleotide metabolism were negatively correlated with the expression of BRAF in the high-risk group. Function analysis revealed that the upregulated genes in the high-risk group were enriched in the cytochrome P450-mediated metabolism of chemical carcinogens. Furthermore, the low-risk group had high levels of gamma delta T cells infiltration, while regulatory T cells were accumulated in the high-risk group. The present study offers a promising new prognostic signature for CM, and provides insight into the mechanisms of melanoma progression.