Cas9 functions by forming a complex with a guide RNA (gRNA). This complex identifies and binds to a specific DNA sequence through complementary base pairing. Once the target DNA is located, Cas9 introduces a double-strand break, which can then be repaired by the cell's natural repair mechanisms. This process can be harnessed for gene editing, enabling scientists to add, remove, or alter genetic material.