Short-term memories link events separated in time, such as past sensation and future actions. Short-term memories are correlated with slow neural dynamics, including selective persistent activity, which can be maintained over seconds. In a delayed response task that requires short-term memory, neurons in the mouse anterior lateral motor cortex (ALM) show persistent activity that instructs future actions. To determine the principles that underlie this persistent activity, here we combined intracellular and extracellular electrophysiology with optogenetic perturbations and network modelling. We show that during the delay epoch, the activity of ALM neurons moved towards discrete end points that correspond to specific movement directions. These end points were robust to transient shifts in ALM activity caused by optogenetic perturbations. Perturbations occasionally switched the population dynamics to the other end point, followed by incorrect actions. Our results show that discrete attractor dynamics underlie short-term memory related to motor planning.