Chlorhexidine works by disrupting the cell membranes of bacteria, leading to leakage of cell contents and ultimately cell death. This mechanism makes it effective against a broad spectrum of Gram-positive and Gram-negative bacteria, fungi, and some viruses.