Type 1 diabetes mellitus (T1DM) is caused by progressive autoimmune-mediated loss of pancreatic β-cell mass via apoptosis. The onset of T1DM depends on environmental factors that interact with predisposing genes to induce an autoimmune assault against β cells. Epidemiological, clinical and pathology studies in humans support viral infection--particularly by enteroviruses (for example, coxsackievirus)--as an environmental trigger for the development of T1DM. Many candidate genes for T1DM, such as MDA5, PTPN2 and TYK2, regulate antiviral responses in both β cells and the immune system. Cellular permissiveness to viral infection is modulated by innate antiviral responses that vary among different tissues or cell types. Some data indicate that pancreatic islet α cells trigger a more efficient antiviral response to infection with diabetogenic viruses than do β cells, and so are able to eradicate viral infections without undergoing apoptosis. This difference could account for the varying ability of islet-cell subtypes to clear viral infections and explain why chronically infected pancreatic β cells, but not α cells, are targeted by an autoimmune response and killed during the development of T1DM. These issues and attempts to target viral infection as a preventive therapy for T1DM are discussed in the present Review.