Medium-ring lactones are synthetically challenging due to unfavorable energetics involved in cyclization. We have discovered a thioesterase enzyme DcsB, from the decarestrictine C1 (1) biosynthetic pathway, that efficiently performs medium-ring lactonizations. DcsB shows broad substrate promiscuity toward linear substrates that vary in lengths and substituents, and is a potential biocatalyst for lactonization. X-ray crystal structure and computational analyses provide insights into the molecular basis of catalysis.