Animals perform an extraordinary variety of movements over many different time scales. To support this diversity, the motor cortex (M1) exhibits a similarly rich repertoire of activity. Although recent neuronal network models capture many qualitative aspects of M1 dynamics, such as complex multiphasic activity transients, they can generate only a few distinct movements. Additionally, it is unclear how M1 efficiently controls movements over a wide range of speeds and shapes. Here we demonstrate that simple modulation of neuronal input--output gains in recurrent network models with fixed connectivity can substantially and predictably affect downstream muscle outputs. Consistent with the observation of diffuse neuromodulatory projections to motor areas, our results suggest that a relatively small number of modulatory control units can provide sufficient flexibility to adjust high-dimensional network activity on behaviourally relevant time scales. Such modulatory gain patterns can be obtained through a simple reward-based learning rule. Novel movements can also be assembled from previously learned primitives, thereby facilitating fast acquisition of hitherto untrained muscle outputs. Moreover, we show that it is possible to separately change movement speed while preserving movement shape, thus enabling efficient and independent movement control in space and time. Our results provide a new perspective on the role of neuromodulatory systems in controlling recurrent cortical activity and suggests plasticity of single-neuron excitability as an important substrate of learning.