White matter hyperintensities (WMH) have been extensively associated with cognitive impairment and reductions in gray matter volume (GMv) independently. This study explored whether WMH lesion volume mediates the relationship between cerebral patterns of GMv and cognition in 521 (mean age 57.7 years) cognitively unimpaired middle-aged individuals. Episodic memory (EM) was measured with the Memory Binding Test and executive functions (EF) using five WAIS-IV subtests. WMH were automatically determined from T2 and FLAIR sequences and characterized using diffusion-weighted imaging (DWI) parameters. WMH volume was entered as a mediator in a voxel-wise mediation analysis relating GMv and cognitive performance (with both EM and EF composites and the individual tests independently). The mediation model was corrected by age, sex, education, number of Apolipoprotein E (APOE)-ε4 alleles and total intracranial volume. We found that even at very low levels of WMH burden in the cohort (median volume of 3.2 mL), higher WMH lesion volume was significantly associated with a widespread pattern of lower GMv in temporal, frontal, and cerebellar areas. WMH mediated the relationship between GMv and EF, mainly driven by processing speed, but not EM. DWI parameters in these lesions were compatible with incipient demyelination and axonal loss. These findings lead to the reflection on the relevance of the control of cardiovascular risk factors in middle-aged individuals as a valuable preventive strategy to reduce or delay cognitive decline.