Polyketides are a class of biologically active microbial and plant-derived metabolites that possess a high degree of structural and functional diversity and include many human therapeutics, among them anti-infective and anti-cancer drugs, growth promoters and anti-parasitic agents. The macrolide antibiotics, characterized by a glycoside-linked macrolactone, constitute an important class of polyketides, including erythromycin and the natural ketolide anti-infective agent pikromycin. Here we describe new mechanistic details of macrolactone ring formation catalyzed by the pikromycin polyketide synthase thioesterase domain from Streptomyces venezuelae. A pentaketide phosphonate mimic of the final pikromycin linear chain-elongation intermediate was synthesized and shown to be an active site affinity label. The crystal structures of the affinity-labeled enzyme and of a 12-membered-ring macrolactone product complex suggest a mechanism for cyclization in which a hydrophilic barrier in the enzyme and structural restraints of the substrate induce a curled conformation to direct macrolactone ring formation.