Circadian clocks create a 24-hour temporal structure, which allows organisms to occupy a niche formed by time rather than space. They are pervasive throughout nature, yet they remain unexpectedly unexplored and uncharacterized in nonphotosynthetic bacteria. Here, we identify in Bacillus subtilis circadian rhythms sharing the canonical properties of circadian clocks: free-running period, entrainment, and temperature compensation. We show that gene expression in B. subtilis can be synchronized in 24-hour light or temperature cycles and exhibit phase-specific characteristics of entrainment. Upon release to constant dark and temperature conditions, bacterial biofilm populations have temperature-compensated free-running oscillations with a period close to 24 hours. Our work opens the field of circadian clocks in the free-living, nonphotosynthetic prokaryotes, bringing considerable potential for impact upon biomedicine, ecology, and industrial processes.