Clustered, regularly interspaced, short palindromic repeat (CRISPR) loci in prokaryotes are composed of 30-40-base-pair repeats separated by equally short sequences of plasmid and bacteriophage origin known as spacers1-3. These loci are transcribed and processed into short CRISPR RNAs (crRNAs) that are used as guides by CRISPR-associated (Cas) nucleases to recognize and destroy complementary sequences (known as protospacers) in foreign nucleic acids4,5. In contrast to most Cas nucleases, which destroy invader DNA4-7, the type VI effector nuclease Cas13 uses RNA guides to locate complementary transcripts and catalyse both sequence-specific cis- and non-specific trans-RNA cleavage8. Although it has been hypothesized that Cas13 naturally defends against RNA phages8, type VI spacer sequences have exclusively been found to match the genomes of double-stranded DNA phages9,10, suggesting that Cas13 can provide immunity against these invaders. However, whether and how Cas13 uses its cis- and/or trans-RNA cleavage activities to defend against double-stranded DNA phages is not understood. Here we show that trans-cleavage of transcripts halts the growth of the host cell and is sufficient to abort the infectious cycle. This depletes the phage population and provides herd immunity to uninfected bacteria. Phages that harbour target mutations, which easily evade DNA-targeting CRISPR systems11-13, are also neutralized when Cas13 is activated by wild-type phages. Thus, by acting on the host rather than directly targeting the virus, type VI CRISPR systems not only provide robust defence against DNA phages but also prevent outbreaks of CRISPR-resistant phage.