Bacteria and archaea insert spacer sequences acquired from foreign DNAs into CRISPR loci to generate immunological memory. The Escherichia coli Cas1-Cas2 complex mediates spacer acquisition in vivo, but the molecular mechanism of this process is unknown. Here we show that the purified Cas1-Cas2 complex integrates oligonucleotide DNA substrates into acceptor DNA to yield products similar to those generated by retroviral integrases and transposases. Cas1 is the catalytic subunit and Cas2 substantially increases integration activity. Protospacer DNA with free 3'-OH ends and supercoiled target DNA are required, and integration occurs preferentially at the ends of CRISPR repeats and at sequences adjacent to cruciform structures abutting AT-rich regions, similar to the CRISPR leader sequence. Our results demonstrate the Cas1-Cas2 complex to be the minimal machinery that catalyses spacer DNA acquisition and explain the significance of CRISPR repeats in providing sequence and structural specificity for Cas1-Cas2-mediated adaptive immunity.