Spontaneous animal behavior exhibits a striking amount of variability in the temporal domain. Concatenating movements into action sequences and long-term behavioral plans relies on a hierarchy of timescales ranging from milliseconds to minutes. Moreover, the timing of the same action may vary wildly across repetitions and depending on the context and the behavioral state. How do action sequences emerge from neural activity and what mechanisms underlie the variability in their timing? Can neural circuits naturally generate the large hierarchy of timescales observed in behavior? In this talk, we will present a theory of cortical computation via metastable dynamics underlying temporal variability in brain activity and behavior. First, we will show how neural activity from premotor areas unfolds through temporal sequences of metastable attractors, which predict the intention to act and explain the observed variability in action timing. We will then show how a large hierarchy of timescales, ranging from milliseconds to minutes, can naturally arise from heterogeneities in the functional architecture of neural circuits. Finally, we will show how neuromodulatory signals can flexibly regulate reaction times to flexibly adapt to different behavioral contexts.