Since the first demonstration that CRISPR-Cas systems provide bacteria and archaea with adaptive immunity against phages and plasmids, numerous studies have yielded key insights into the molecular mechanisms governing how these systems attack and degrade foreign DNA. However, the molecular mechanisms underlying the adaptation stage, in which new immunological memory is formed, have until recently represented a major unresolved question. In this Progress article, we discuss recent discoveries that have shown both how foreign DNA is identified by the CRISPR-Cas adaptation machinery and the molecular basis for its integration into the chromosome to form an immunological memory. Furthermore, we describe the roles of each of the specific CRISPR-Cas components that are involved in memory formation, and consider current models for their evolutionary origin.