Prokaryotes contain short DN repeats known as CRISPR, recognizable by the regular spacing existing between the recurring units. They represent the most widely distributed family of repeats among prokaryotic genomes suggesting a biological function. The origin of the intervening sequences, at present unknown, could provide clues about their biological activities. Here we show that CRISPR spacers derive from preexisting sequences, either chromosomal or within transmissible genetic elements such as bacteriophages and conjugative plasmids. Remarkably, these extrachromosomal elements fail to infect the specific spacer-carrier strain, implying a relationship between CRISPR and immunity against targeted DNA. Bacteriophages and conjugative plasmids are involved in prokaryotic population control, evolution, and pathogenicity. All these biological traits could be influenced by the presence of specific spacers. CRISPR loci can be visualized as mosaics of a repeated unit, separated by sequences at some time present elsewhere in the cell.