In adults, there are differences between male and female structural and functional brain connectivity, specifically for those regions involved in pain processing. This may partly explain the observed sex differences in pain sensitivity, tolerance, and inhibitory control, and in the development of chronic pain. However, it is not known if these differences exist from birth. Cortical activity in response to a painful stimulus can be observed in the human neonatal brain, but this nociceptive activity continues to develop in the postnatal period and is qualitatively different from that of adults, partly due to the considerable cortical maturation during this time. This research aimed to investigate the effects of sex and prematurity on the magnitude and spatial distribution pattern of the long-latency nociceptive event-related potential (nERP) using electroencephalography (EEG). We measured the cortical response time-locked to a clinically required heel lance in 81 neonates born between 29 and 42 weeks gestational age (median postnatal age 4 days). The results show that heel lance results in a spatially widespread nERP response in the majority of newborns. Importantly, a widespread pattern is significantly more likely to occur in females, irrespective of gestational age at birth. This effect is not observed for the short latency somatosensory waveform in the same infants, indicating that it is selective for the nociceptive component of the response. These results suggest the early onset of a greater anatomical and functional connectivity reported in the adult female brain, and indicate the presence of pain-related sex differences from birth.