The Toll/interleukin-1 receptor (TIR) domain is a canonical component of animal and plant immune systems. In plants, intracellular pathogen sensing by immune receptors triggers their TIR domains to generate a molecule which is a variant of cyclic ADP-ribose (v-cADPR). This molecule is hypothesized to activate plant cell death via a yet unresolved pathway. TIR domains were recently also shown to be involved in a bacterial anti-phage defense system called Thoeris, but the mechanism of Thoeris defense remained unknown. In this study we report that phage infection triggers Thoeris TIR-domain proteins to produce an isomer of cyclic ADP-ribose. This molecular signal activates a second protein, ThsA, which then depletes the cell of the essential molecule nicotinamide adenine dinucleotide (NAD) and leads to abortive infection and cell death. We further show that similar to eukaryotic innate immune systems, bacterial TIR-domain proteins determine the immunological specificity to the invading pathogen. Our results describe a new antiviral signaling pathway in bacteria, and suggest that generation of intracellular signaling molecules is an ancient immunological function of TIR domains conserved in both plant and bacterial immunity.