The RNA-guided CRISPR-associated (Cas) proteins Cas9 and Cas12a provide adaptive immunity against invading nucleic acids, and function as powerful tools for genome editing in a wide range of organisms. Here we reveal the underlying mechanisms of a third, fundamentally distinct RNA-guided genome-editing platform named CRISPR–CasX, which uses unique structures for programmable double-stranded DNA binding and cleavage. Biochemical and in vivo data demonstrate that CasX is active for Escherichia coli and human genome modification. Eight cryo-electron microscopy structures of CasX in different states of assembly with its guide RNA and double-stranded DNA substrates reveal an extensive RNA scaffold and a domain required for DNA unwinding. These data demonstrate how CasX activity arose through convergent evolution to establish an enzyme family that is functionally separate from both Cas9 and Cas12a.