Across a range of motor and cognitive tasks, cortical activity can be accurately described by low-dimensional dynamics unfolding from specific initial conditions on every trial. These "preparatory states" largely determine the subsequent evolution of both neural activity and behaviour, and their importance raises questions regarding how they are -or ought to be -set. Here, we formulate motor preparation as optimal prospective control of future movements. The solution is a form of internal control of cortical circuit dynamics, which can be implemented as a thalamo-cortical loop gated by the basal ganglia. Critically, optimal control predicts selective quenching of variability in components of preparatory population activity that have future motor consequences, but not in others. This is consistent with recent perturbation experiments performed in mice, and with our novel analysis of monkey motor cortex activity during reaching. Together, these results suggest optimal anticipatory control of movement.Fast ballistic movements (e.g. throwing) require spa-1 lamocortical loop during motor preparation, with tha-62 lamic afferents providing the desired optimal control in-63 puts. This is consistent with the causal role of thalamus 64 in the preparation of directed licking in mice (Guo et al., 65 2017). Moreover, we posit that the basal ganglia oper-66 ate an on/off switch on the thalamocortical loop (Jin 67 and Costa, 2010; Cui et al., 2013; Halassa and Acsády, 68 2016; Logiaco et al., 2019), thereby flexibly controlling 69 the timing of both movement planning and initiation.70We further analyze the model, and formulate predic-71 tions which we have successfully tested in data. At the 72 most abstract level, our core prediction is that the "op-73 timal subspace" is likely high dimensional, with many 74 different initial conditions giving rise to the same cor-75 rect movement. This has an important consequence for 76 preparatory control: at the population level, only a few 77 components of preparatory activity impact future mo-78 tor outputs, and it is these components only that need 79 active controlling. In contrast, one expects substantial 80 pre-movement variability in other, inconsequential com-81 ponents. Concretely, we predict that following a pertur-82 bation, preparatory activity should recover only in state 83 space directions that matter for subsequent movement, 84 but not (necessarily) in others. We find that this pre-85 diction agrees with the effects of optogenetic perturba-86 tions reported by Svoboda and colleagues, in a directed 87 licking task in mice (Li et al., 2016). Furthermore, the 88 existence of a preparatory nullspace predicts selective 89 variability quenching at preparation onset: trial-by-trial 90 variability should drop predominantly in components 91 that have motor consequences. We perform novel analy-92 ses of monkey M1 and dorsal premotor cortex (PMd) ac-93 tivity recorded during reaching, and find that the struc-94 ture of variability quenching supports our main predic-95 tion. Finally...