Modular polyketide synthases (PKSs) are giant bacterial enzymes that synthesize many polyketides of therapeutic value. In contrast to PKSs that provide acyltransferase (AT) activities in cis, trans-AT PKSs lack integrated AT domains and exhibit unusual enzymatic features with poorly understood functions in polyketide assembly. This has retarded insight into the assembly of products such as mupirocin, leinamycin and bryostatin 1. We show that trans-AT PKSs evolved in a fundamentally different fashion from cis-AT systems, through horizontal recruitment and assembly of substrate-specific ketosynthase (KS) domains. The insights obtained from analysis of these KS mosaics will facilitate both the discovery of novel polyketides by genome mining, as we demonstrate for the thailandamides of Burkholderia thailandensis, and the extraction of chemical information from short trans-AT PCR products, as we show using metagenomic DNA of marine sponges. Our data also suggest new strategies for dissecting polyketide biosynthetic pathways and engineering polyketide assembly.