Spontaneous and sensory-evoked cortical activity is highly state-dependent, yet relatively little is known about transitions between the distinct waking states that are associated with cognition and perception. In addition, transitions between distinct states highlight the full dynamic range of local circuit activity and allow us to examine how cortical activity is optimized for different operations according to behavioral and environmental context. Patterns of activity in mouse primary visual cortex (V1) differ dramatically between quiescence and locomotion, but this difference could be explained by either motor feedback or a change in arousal levels. Using naturally occurring and induced behavioral state transitions, we dissociated arousal and locomotion effects in V1. Arousal suppressed spontaneous firing and strongly altered the temporal patterning of population activity. Moreover, heightened arousal increased the signal-to-noise ratio of visual responses and reduced noise correlations. Putative excitatory and inhibitory neurons were differentially regulated by state transitions. In animals performing a visual task, we found a consistent level of arousal associated with a stably maintained cortical state. Our findings suggest complementary roles of arousal and locomotion in promoting functional flexibility in cortical circuits.