Suicide upon infection by lytic phages is known in several bacteria species and represents an effective defence strategy to limit phage spread. However, the ecological conditions favouring the evolution of such a radically altruistic behaviour are unclear. Here, we model the feedback of epidemiology on host evolution in a spatially structured environment and we generate several specific predictions on altruistic suicide evolution. We test these predictions experimentally by competing E. coli cells carrying the suicide gene Lit against non-carrier cells in the presence or in the absence of the lytic phage T6. We show that in accord with our theoretical analysis altruistic suicide is only favoured in the presence of the phage in spatially structured environments at intermediate levels of mixing. Our work provides a general explanation for the evolution of altruistic defence strategies against pathogens. We discuss the implications of these results for oncolytic virus therapy.