The project EvoSpore was funded by the Portuguese Foundation for Science and Technology. The goal was to uncover the origin and evolution of bacterial endosporulation through comparative genomics. Endosporulation is a developmental pathway that initiates from the vegetative cell and culminates with the formation of highly resistant, dormant spores. Spores are everywhere, they allow environmental persistence, dissemination and, for pathogens, are infection vehicles. We found that for the model Bacillus subtilis and for the pathogen Clostridioides difficile, sporulation was shapped by two major evolutionary transitions. The first one was at the base of the Firmicutes and the second one at the base of the B. subtilis group and within the Peptostreptococcaceae family, which includes C. difficile. We also found that early and late sporulation regulons have been coevolving and that sporulation genes entail greater innovation in B. subtilis with many Bacilli lineage-restricted genes. In contrast, C. difficile more often recruits new sporulation genes by horizontal gene transfer, which reflects both its highly mobile genome, the complexity of the gut microbiota, and an adjustment of sporulation to the gut ecosystem.