The immune response to melanoma improves the survival in untreated patients and predicts the response to immune checkpoint blockade. Here, we report genetic and environmental predictors of the immune response in a large primary cutaneous melanoma cohort. Bioinformatic analysis of 703 tumor transcriptomes was used to infer immune cell infiltration and to categorize tumors into immune subgroups, which were then investigated for association with biological pathways, clinicopathologic factors, and copy number alterations. Three subgroups, with “low”, “intermediate”, and “high” immune signals, were identified in primary tumors and replicated in metastatic tumors. Genes in the low subgroup were enriched for cell-cycle and metabolic pathways, whereas genes in the high subgroup were enriched for IFN and NF-κB signaling. We identified high MYC expression partially driven by amplification, HLA-B downregulation, and deletion of IFNγ and NF-κB pathway genes as the regulators of immune suppression. Furthermore, we showed that cigarette smoking, a globally detrimental environmental factor, modulates immunity, reducing the survival primarily in patients with a strong immune response. Together, these analyses identify a set of factors that can be easily assessed that may serve as predictors of response to immunotherapy in patients with melanoma.