CRISPR-Cas systems protect bacteria and archaea from phages and other mobile genetic elements, which use small anti-CRISPR (Acr) proteins to overcome CRISPR-Cas immunity. Because Acrs are challenging to identify, their natural diversity and impact on microbial ecosystems are underappreciated. To overcome this discovery bottleneck, we developed a high-throughput functional selection to isolate ten DNA fragments from human oral and fecal metagenomes that inhibit Streptococcus pyogenes Cas9 (SpyCas9) in Escherichia coli. The most potent Acr from this set, AcrIIA11, was recovered from a Lachnospiraceae phage. We found that AcrIIA11 inhibits SpyCas9 in bacteria and in human cells. AcrIIA11 homologs are distributed across diverse bacteria; many distantly-related homologs inhibit both SpyCas9 and a divergent Cas9 from Treponema denticola. We find that AcrIIA11 antagonizes SpyCas9 using a different mechanism than other previously characterized Type II-A Acrs. Our study highlights the power of functional selection to uncover widespread Cas9 inhibitors within diverse microbiomes.