We report the discovery that strains of Staphylococcus epidermidis produce 6-N-hydroxyaminopurine (6-HAP), a molecule that inhibits DNA polymerase activity. In culture, 6-HAP selectively inhibited proliferation of tumor lines but did not inhibit primary keratinocytes. Resistance to 6-HAP was associated with the expression of mitochondrial amidoxime reducing components, enzymes that were not observed in cells sensitive to this compound. Intravenous injection of 6-HAP in mice suppressed the growth of B16F10 melanoma without evidence of systemic toxicity. Colonization of mice with an S. epidermidis strain producing 6-HAP reduced the incidence of ultraviolet-induced tumors compared to mice colonized by a control strain that did not produce 6-HAP. S. epidermidis strains producing 6-HAP were found in the metagenome from multiple healthy human subjects, suggesting that the microbiome of some individuals may confer protection against skin cancer. These findings show a new role for skin commensal bacteria in host defense.