The actions of dopamine in the basal ganglia are important for the transformation of a repeated action into an automated habit; however, the precise mechanisms by which dopamine is modulated during habit learning are unclear. Here, the authors show that mice in which NMDAR1 is deleted from dopamine neurons are impaired in several habit-learning tasks, suggesting that the modulation of dopamine neurons by glutamate via NMDA receptors makes a crucial contribution to habit learning.