Aims/hypothesis Biological ageing of the immune system, or immunosenescence, predicts poor health and increased mortality. A hallmark of immunosenescence is the accumulation of differentiated cytotoxic T cells (CD27−CD45RA+/−; or dCTLs), partially driven by infection with the cytomegalovirus (CMV). Immune impairments reminiscent of immunosenescence are also observed in hyperglycaemia, and in vitro studies have illustrated mechanisms by which elevated glucose can lead to increased dCTLs. This study explored associations between glucose dysregulation and markers of immunosenescence in CMV+ and CMV− individuals. Methods A cross-sectional sample of participants from an occupational cohort study (n = 1,103, mean age 40 years, 88% male) were assessed for HbA1c and fasting glucose levels, diabetes, cardiovascular risk factors (e.g. lipids), numbers of circulating effector memory (EM; CD27−CD45RA−) and CD45RA re-expressing effector memory (EMRA; CD27−CD45RA+) T cells, and CMV infection status. Self-report and physical examination assessed anthropometric, sociodemographic and lifestyle factors. Results Among CMV+ individuals (n = 400), elevated HbA1c was associated with increased numbers of EM (B = 2.75, p < 0.01) and EMRA (B = 2.90, p < 0.01) T cells, which was robust to adjustment for age, sex, sociodemographic variables and lifestyle factors. Elevated EM T cells were also positively associated with total cholesterol (B = 0.04, p < 0.05) after applying similar adjustments. No associations were observed in CMV− individuals. Conclusions/interpretation The present study identified consistent associations of unfavourable glucose and lipid profiles with accumulation of dCTLs in CMV+ individuals. These results provide evidence that the impact of metabolic risk factors on immunity and health can be co-determined by infectious factors, and provide a novel pathway linking metabolic risk factors with accelerated immunosenescence. Electronic supplementary material The online version of this article (doi:10.1007/s00125-015-3731-4) contains peer-reviewed but unedited supplementary material, which is available to authorised users.