The sulfonamide antibiotics inhibit dihydropteroate synthase (DHPS), a key enzyme in the folate pathway of bacteria and primitive eukaryotes. However, resistance mutations have severely compromised the usefulness of these drugs. We report structural, computational, and mutagenesis studies on the catalytic and resistance mechanisms of DHPS. By performing the enzyme-catalyzed reaction in crystalline DHPS, we have structurally characterized key intermediates along the reaction pathway. Results support an SN1 reaction mechanism via formation of a novel cationic pterin intermediate. We also show that two conserved loops generate a substructure during catalysis that creates a specific binding pocket for p-aminobenzoic acid, one of the two DHPS substrates. This substructure, together with the pterin-binding pocket, explains the roles of the conserved active-site residues and reveals how sulfonamide resistance arises.