26Bacteria of the Firmicutes phylum are able to enter a developmental pathway that 27 culminates with the formation of a highly resistant, dormant spore. Spores allow 28 environmental persistence, dissemination and for pathogens, are infection vehicles. 29In both the model Bacillus subtilis, an aerobic species, and in the intestinal 30 pathogen Clostridioides difficile, an obligate anaerobe, sporulation mobilizes 31 hundreds of genes. Their expression is coordinated between the forespore and the 32 mother cell, the two cells that participate in the process, and is kept in close register 33 with the course of morphogenesis. The evolutionary mechanisms by which 34 sporulation emerged and evolved in these two species, and more broadly across 35Firmicutes, remain largely unknown. Here, we trace the origin and evolution of 36 sporulation. Using the genes involved in the process in B. subtilis and C. difficile, and 37 estimating their gain-loss dynamics in a comprehensive bacterial macro-evolutionary 38 framework we show that sporulation evolution was driven by two major gene gain 39 events, the first at the base of the Firmicutes and the second at the base of the B. 40 subtilis group and within the Peptostreptococcaceae family, which 41 includes C. difficile. We also show that early and late sporulation regulons have been 42