Bacteria and archaea acquire resistance to viruses and plasmids by integrating short fragments of foreign DNA into clustered regularly interspaced short palindromic repeats (CRISPRs). These repetitive loci maintain a genetic record of all prior encounters with foreign transgressors. CRISPRs are transcribed and the long primary transcript is processed into a library of short CRISPR-derived RNAs (crRNAs) that contain a unique sequence complementary to a foreign nucleic-acid challenger. In Escherichia coli, crRNAs are incorporated into a multisubunit surveillance complex called Cascade (CRISPR-associated complex for antiviral defence), which is required for protection against bacteriophages. Here we use cryo-electron microscopy to determine the subnanometre structures of Cascade before and after binding to a target sequence. These structures reveal a sea-horse-shaped architecture in which the crRNA is displayed along a helical arrangement of protein subunits that protect the crRNA from degradation while maintaining its availability for base pairing. Cascade engages invading nucleic acids through high-affinity base-pairing interactions near the 5' end of the crRNA. Base pairing extends along the crRNA, resulting in a series of short helical segments that trigger a concerted conformational change. This conformational rearrangement may serve as a signal that recruits a trans-acting nuclease (Cas3) for destruction of invading nucleic-acid sequences.