Viral infection is a major contributor to the global cancer burden. Recent advances have revealed that seven known oncogenic viruses promote tumorigenesis through shared host cell targets and pathways. A comprehensive understanding of the principles of viral oncogenesis may enable the identification of unknown infectious aetiologies of cancer and the development of therapeutic or preventive strategies for virus-associated cancers. In this Review, we discuss the molecular mechanisms of viral oncogenesis in humans. We highlight recent advances in understanding how viral manipulation of host cellular signalling, DNA damage responses, immunity and microRNA targets promotes the initiation and development of cancer.