Regulation of physiological functions with approximate daily periodicity, or circadian rhythms, is a characteristic feature of eukaryotes. Until recently, cyanobacteria were the only prokaryotes reported to possess circadian rhythmicity. It is controlled by a cluster of three genes: kaiA, kaiB, and kaiC. Using sequence data of ≈70 complete prokaryotic genomes from the various public depositories, we show here that the kai genes and their homologs have quite a different evolutionary history and occur in Archaea and Proteobacteria as well. Among the three genes, kaiC is evolutionarily the oldest, and kaiA is the youngest and likely evolved only in cyanobacteria. Our data suggest that the prokaryotic circadian pacemakers have evolved in parallel with the geological history of the earth, and that natural selection, multiple lateral transfers, and gene duplications and losses have been the major factors shaping their evolution.