The aim of this study was to analyse the differences in cognitive function between women and men with type-2 diabetes mellitus (DMT2) and diabetic peripheral neuropathy (DPN) with and without diabetic neuropathic pain (DNP), and the factors associated with cognitive function in each sex. A cross-sectional study of 149 patients with DMT2 and DPN was performed. Sociodemographic and clinical variables, Test Your Memory (TYM) for cognitive assessment, anxiety and depression (HADS), quality of life (SF-12v2) and sleep characteristics (MOS-sleep) were measured. A high percentage of women presented cognitive impairment (50% vs. 36.1%) and they scored lower on the TYM (mean = 40.77; SD = 6.03 vs. mean = 42.49; SD = 6.05). Women with DNP scored lower on calculation tasks (3.17 vs. 3.52) than men with DNP, while women without DNP scored lower on retrograde memory (2.70 vs. 3.74), executive function (3.83 vs. 4.25) and similarities (2.51 vs. 3.12) than men without DNP. Being older (B = -0.181) and presenting cardiovascular risk factors (B = -5.059) were associated with worse cognitive function in women, while in men this was associated with older age (B = -0.154), a longer duration of diabetes (B = -0.319) and the presence of depression (B = -0.363). Women with and without DNP obtained worse results in cognitive function. However, the presence of pain had a greater impact on the different dimensions in men.