Mechanistic insights into the role of the human microbiome in the predisposition to and treatment of disease are limited by the lack of methods to precisely add or remove microbial strains or genes from complex communities. Here, we demonstrate that engineered bacteriophage M13 can be used to deliver DNA to Escherichia coli within the mouse gastrointestinal (GI) tract. Delivery of a programmable exogenous CRISPR-Cas9 system enabled the strain-specific depletion of fluorescently marked isogenic strains during competitive colonization and genomic deletions that encompass the target gene in mice colonized with a single strain. Multiple mechanisms enabled E. coli to escape targeting, including loss of the CRISPR array or even the entire CRISPR-Cas9 system. These results provide a robust and experimentally tractable platform for microbiome editing, a foundation for the refinement of this approach to increase targeting efficiency, and a proof-of-concept for the extension to other phage-bacterial pairs of interest.