Evolutionary events leading to organismal preference for a specific growth temperature, as well as genes whose products are needed for a proper function at that temperature, are poorly understood. Using 64 bacteria from phylumThermotogotaas a model system, we examined how optimal growth temperature changed throughoutThermotogotahistory. We inferred thatThermotogota’s last common ancestor was a thermophile and that someThermotogotaevolved the mesophilic and hyperthermophilic lifestyles secondarily. By modeling gain and loss of genes throughoutThermotogotahistory and by reconstructing their phylogenies, we demonstrated that adaptations to lower and higher growth temperature require both the acquisition of necessary genes and loss of unnecessary genes. Via a pangenome-wide association study, we correlated presence/absence of 68 gene families with specific optimal growth temperature intervals. While some of these genes are poorly characterized, most are involved in metabolism of amino acids, nucleotides, carbohydrates, and lipids, as well as in signal transduction and regulation of transcription. Most of the 68 genes have a history of horizontal gene transfer to/from other bacteria and archaea, suggesting that parallel acquisitions of genes likely promote independent adaptations of differentThermotogotaspecies to specific growth temperatures.SignificanceWhile the currently known range of life-permitting temperatures spans from −15°C to +122°C, most living organisms, including microbes, can grow only in a narrow temperature interval around their optimal growth temperature. The genetic and genomic determinants of such preference remain poorly understood. Using genomes fromThermotogota, a group of bacteria that collectively can grow between 20° and 90°C, we detected 68 genes, presence of which strongly correlates with growth at specific optimal growth temperature. Our findings dramatically expand a list of genes that are likely important for both lowering and increasing preferred growth temperature of a microorganism. We also demonstrated that these genes were usually horizontally acquired from other bacteria and archaea that likely share environment withThermotogota, highlighting the importance of gene exchange in microbial adaptation.