Several structures of the Enteroccocus faecalis Cas1–Cas2 proteins are solved, and help to define the spacer integration mechanisms of type II CRISPR systems. To protect themselves from invading viruses, bacteria integrate short pieces of the viral genome known as spacers into their own genome. This bacterial immunity process is known as CRISPR. There has been intensive study into how this stored information is used to degrade viruses to which the bacteria have previously been exposed, but the integration process itself is less well understood. Ailong Ke and colleagues have solved several structures along the spacer integration pathway, defining the mechanism of the process for type II CRISPR systems. CRISPR (clustered regularly interspaced short palindromic repeats) and the nearby Cas (CRISPR-associated) operon establish an RNA-based adaptive immunity system in prokaryotes1,2,3,4,5. Molecular memory is created when a short foreign DNA-derived prespacer is integrated into the CRISPR array as a new spacer6,7,8,9. Whereas the RNA-guided CRISPR interference mechanism varies widely among CRISPR–Cas systems, the spacer integration mechanism is essentially identical7,8,9. The conserved Cas1 and Cas2 proteins form an integrase complex consisting of two distal Cas1 dimers bridged by a Cas2 dimer6,10. The prespacer is bound by Cas1–Cas2 as a dual-forked DNA, and the terminal 3′-OH of each 3′ overhang serves as an attacking nucleophile during integration11,12,13,14. The prespacer is preferentially integrated into the leader-proximal region of the CRISPR array1,7,10,15, guided by the leader sequence and a pair of inverted repeats inside the CRISPR repeat7,15,16,17,18,19,20. Spacer integration in the well-studied Escherichia coli type I–E CRISPR system also relies on the bacterial integration host factor21,22. In type II–A CRISPR, however, Cas1–Cas2 alone integrates spacers efficiently in vitro18; other Cas proteins (such as Cas9 and Csn2) have accessory roles in the biogenesis phase of prespacers17,23. Here we present four structural snapshots from the type II–A system24 of Enterococcus faecalis Cas1 and Cas2 during spacer integration. Enterococcus faecalis Cas1–Cas2 selectively binds to a splayed 30-base-pair prespacer bearing 4-nucleotide 3′ overhangs. Three molecular events take place upon encountering a target: first, the Cas1–Cas2–prespacer complex searches for half-sites stochastically, then it preferentially interacts with the leader-side CRISPR repeat, and finally, it catalyses a nucleophilic attack that connects one strand of the leader-proximal repeat to the prespacer 3′ overhang. Recognition of the spacer half-site requires DNA bending and leads to full integration. We derive a mechanistic framework to explain the stepwise spacer integration process and the leader-proximal preference.