Innate immunity is the first line of defence against pathogens and is essential for survival of the infected host. The fruit fly Drosophila melanogaster is an emerging model to study viral pathogenesis, yet antiviral defence responses remain poorly understood. Here, we describe the heat shock response, a cellular mechanism that prevents proteotoxicity, as a component of the antiviral immune response in Drosophila. Transcriptome analyses of Drosophila S2 cells and adult flies revealed strong induction of the heat shock response upon RNA virus infection. Dynamic induction patterns of heat shock pathway components were characterized in vitro and in vivo following infection with different classes of viruses. The heat shock transcription factor (Hsf), as well as active viral replication, were necessary for the induction of the response. Hsf-deficient adult flies were hypersensitive to virus infection, indicating a role of the heat shock response in antiviral defence. In accordance, transgenic activation of the heat shock response prolonged survival time after infection and enabled long-term control of virus replication to undetectable levels. Together, our results establish the heat shock response as an important constituent of innate antiviral immunity in Drosophila.