The motor cortex controls skilled arm movement by sending temporal patterns of activity to lower motor centres(1). Local cortical dynamics are thought to shape these patterns throughout movement execution(2-4). External inputs have been implicated in setting the initial state of the motor cortex(5,6), but they may also have a pattern-generating role. Here we dissect the contribution of local dynamics and inputs to cortical pattern generation during a prehension task in mice. Perturbing cortex to an aberrant state prevented movement initiation, but after the perturbation was released, cortex either bypassed the normal initial state and immediately generated the pattern that controls reaching or failed to generate this pattern. The difference in these two outcomes was probably a result of external inputs. We directly investigated the role of inputs by inactivating the thalamus