Antibiotics target conserved bacterial cellular pathways or growth functions and therefore cannot selectively kill specific members of a complex microbial population. Here, we develop programmable, sequence-specific antimicrobials using the RNA-guided nuclease Cas9 (refs.1,2) delivered by a bacteriophage. We show that Cas9, reprogrammed to target virulence genes, kills virulent, but not avirulent, Staphylococcus aureus. Reprogramming the nuclease to target antibiotic resistance genes destroys staphylococcal plasmids that harbor antibiotic resistance genes and immunizes avirulent staphylococci to prevent the spread of plasmid-borne resistance genes. We also show that CRISPR-Cas9 antimicrobials function in vivo to kill S. aureus in a mouse skin colonization model. This technology creates opportunities to manipulate complex bacterial populations in a sequence-specific manner.