Immunosuppression increases the risk of cancers that are associated with viral infection1. In particular, the risk of squamous cell carcinoma of the skin-which has been associated with beta human papillomavirus (β-HPV) infection-is increased by more than 100-fold in immunosuppressed patients2-4. Previous studies have not established a causative role for HPVs in driving the development of skin cancer. Here we show that T cell immunity against commensal papillomaviruses suppresses skin cancer in immunocompetent hosts, and the loss of this immunity-rather than the oncogenic effect of HPVs-causes the markedly increased risk of skin cancer in immunosuppressed patients. To investigate the effects of papillomavirus on carcinogen-driven skin cancer, we colonized several strains of immunocompetent mice with mouse papillomavirus type 1 (MmuPV1)5. Mice with natural immunity against MmuPV1 after colonization and acquired immunity through the transfer of T cells from immune mice or by MmuPV1 vaccination were protected against skin carcinogenesis induced by chemicals or by ultraviolet radiation in a manner dependent on CD8+ T cells. RNA and DNA in situ hybridization probes for 25 commensal β-HPVs revealed a significant reduction in viral activity and load in human skin cancer compared with the adjacent healthy skin, suggesting a strong immune selection against virus-positive malignant cells. Consistently, E7 peptides from β-HPVs activated CD8+ T cells from unaffected human skin. Our findings reveal a beneficial role for commensal viruses and establish a foundation for immune-based approaches that could block the development of skin cancer by boosting immunity against the commensal HPVs present in all of our skin.