Melanoma is one of the tumor types with the highest risk of brain metastasis. However, the biology of melanoma brain metastasis and the role of the brain immune microenvironment in treatment responses are not yet fully understood. Using preclinical models and single-cell transcriptomics, we have identified a mechanism that enhances antitumor immunity in melanoma brain metastasis. We show that activation of the Rela/Nuclear Factor κB (NF-κB) pathway in microglia promotes melanoma brain metastasis. Targeting this pathway elicits microglia reprogramming toward a proinflammatory phenotype, which enhances antitumor immunity and reduces brain metastatic burden. Furthermore, we found that proinflammatory microglial markers in melanoma brain metastasis are associated with improved responses to immune checkpoint inhibitors in patients and targeting Rela/NF-κB pathway in mice improves responses to these therapies in the brain, suggesting a strategy to enhance antitumor immunity and responses to immune checkpoint inhibitors in patients with melanoma brain metastasis.