Autophagy, a process of degradation that occurs via the lysosomal pathway, has an essential role in multiple aspects of immunity, including immune system development, regulation of innate and adaptive immune and inflammatory responses, selective degradation of intracellular microorganisms, and host protection against infectious diseases1,2. Autophagy is known to be induced by stimuli such as nutrient deprivation and suppression of mTOR, but little is known about how autophagosomal biogenesis is initiated in mammalian cells in response to viral infection. Here, using genome-wide short interfering RNA screens, we find that the endosomal protein sorting nexin 5 (SNX5)3,4 is essential for virus-induced, but not for basal, stress- or endosome-induced, autophagy. We show that SNX5 deletion increases cellular susceptibility to viral infection in vitro, and that Snx5 knockout in mice enhances lethality after infection with several human viruses. Mechanistically, SNX5 interacts with beclin 1 and ATG14-containing class III phosphatidylinositol-3-kinase (PI3KC3) complex 1 (PI3KC3-C1), increases the lipid kinase activity of purified PI3KC3-C1, and is required for endosomal generation of phosphatidylinositol-3-phosphate (PtdIns(3)P) and recruitment of the PtdIns(3)P-binding protein WIPI2 to virion-containing endosomes. These findings identify a context- and organelle-specific mechanism—SNX5-dependent PI3KC3-C1 activation at endosomes—for initiation of autophagy during viral infection.