Bacteria and Archaea have developed several defence strategies against foreign nucleic acids such as viral genomes and plasmids. Among them, clustered regularly interspaced short palindromic repeats (CRISPR) loci together with cas (CRISPR-associated) genes form the CRISPR/Cas immune system, which involves partially palindromic repeats separated by short stretches of DNA called spacers, acquired from extrachromosomal elements. It was recently demonstrated that these variable loci can incorporate spacers from infecting bacteriophages and then provide immunity against subsequent bacteriophage infections in a sequence-specific manner. Here we show that the Streptococcus thermophilus CRISPR1/Cas system can also naturally acquire spacers from a self-replicating plasmid containing an antibiotic-resistance gene, leading to plasmid loss. Acquired spacers that match antibiotic-resistance genes provide a novel means to naturally select bacteria that cannot uptake and disseminate such genes. We also provide in vivo evidence that the CRISPR1/Cas system specifically cleaves plasmid and bacteriophage double-stranded DNA within the proto-spacer, at specific sites. Our data show that the CRISPR/Cas immune system is remarkably adapted to cleave invading DNA rapidly and has the potential for exploitation to generate safer microbial strains.