Decisions are held in memory until enacted, which makes them potentially vulnerable to distracting sensory input. Gating of information flow from sensory to motor areas could protect memory from interference during decision-making, but the underlying network mechanisms are not understood. Here, we trained mice to detect optogenetic stimulation of the somatosensory cortex, with a delay separating sensation and action. During the delay, distracting stimuli lost influence on behavior over time, even though distractor-evoked neural activity percolated through the cortex without attenuation. Instead, choice-encoding activity in the motor cortex became progressively less sensitive to the impact of distractors. Reverse engineering of neural networks trained to reproduce motor cortex activity revealed that the reduction in sensitivity to distractors was caused by a growing separation in the neural activity space between attractors that encode alternative decisions. Our results show that communication between brain regions can be gated via attractor dynamics, which control the degree of commitment to an action.