Bet hedging-stochastic switching between phenotypic states-is a canonical example of an evolutionary adaptation that facilitates persistence in the face of fluctuating environmental conditions. Although bet hedging is found in organisms ranging from bacteria to humans, direct evidence for an adaptive origin of this behaviour is lacking. Here we report the de novo evolution of bet hedging in experimental bacterial populations. Bacteria were subjected to an environment that continually favoured new phenotypic states. Initially, our regime drove the successive evolution of novel phenotypes by mutation and selection; however, in two (of 12) replicates this trend was broken by the evolution of bet-hedging genotypes that persisted because of rapid stochastic phenotype switching. Genome re-sequencing of one of these switching types revealed nine mutations that distinguished it from the ancestor. The final mutation was both necessary and sufficient for rapid phenotype switching; nonetheless, the evolution of bet hedging was contingent upon earlier mutations that altered the relative fitness effect of the final mutation. These findings capture the adaptive evolution of bet hedging in the simplest of organisms, and suggest that risk-spreading strategies may have been among the earliest evolutionary solutions to life in fluctuating environments.