Habituation to recurrent non-threatening or unavoidable noxious stimuli is an important aspect of adaptation to pain. Neonates, especially if preterm, are exposed to repeated noxious procedures during their clinical care. They can mount strong behavioral, autonomic, spinal, and cortical responses to a single noxious stimulus; however, it is not known whether the developing nervous system can adapt to the recurrence of these inputs. Here, we used electroencephalography to investigate changes in cortical microstates (representing the complex sequential processing of noxious inputs) following two consecutive clinically required heel lances in term and preterm infants. We show that stimulus repetition dampens the engagement of initial microstates and associated behavioral and autonomic responses in term infants, while preterm infants do not show signs of habituation. Nevertheless, both groups engage different longer-latency cortical microstates to each lance, which is likely to reflect changes in higher-level stimulus processing with repeated stimulation. These data suggest that while both age groups are capable of encoding contextual differences in pain, the preterm brain does not regulate the initial cortical, behavioral, and autonomic responses to repeated noxious stimuli. Habituation mechanisms to pain are already in place at term age but mature over the equivalent of the last trimester of gestation and are not fully functional in preterm neonates.