We investigated the impact of recent caffeine drinking on glucose and other biomarkers of cardiometabolic function under free-living conditions while also accounting for lifestyle and genetic factors that alter caffeine metabolism and drinking behaviour. Up to 447 794 UK Biobank participants aged 37–73 years in 2006–2010 provided a non-fasting blood sample, for genetic and biomarker measures, and completed questionnaires regarding sociodemographics, medical history and lifestyle. Caffeine drinking (yes/no) about 1 h before blood collection was also recorded. Multivariable regressions were used to examine the association between recent caffeine drinking and serum levels of glycated Hb, glucose, lipids, apo, lipoprotein(a) and C-reactive protein. Men and women reporting recent caffeine drinking had clinically and significantly higher glucose levels than those not recently drinking caffeine (P < 0·0001). Larger effect sizes were observed among those 55+ years of age and with higher adiposity and longer fasting times (P ≤ 0·02 for interactions). Significant CYP1A2 rs2472297×caffeine and MLXIPL rs7800944 × caffeine interactions on glucose levels were observed among women (P = 0·004), with similar but non-significant interactions in men. Larger effect sizes were observed among women with rs2472297 CC or rs7800944 CC genotypes than among rs2472297 T or rs7800944 T carriers, respectively. In summary, men and women drinking caffeine within about 1 h of blood draw had higher glucose levels than those not drinking caffeine. Findings were modified by age, adiposity, fasting time and genetic factors related to caffeine metabolism and drinking behaviour. Implications for clinical and population studies of caffeine-containing beverages and cardiometabolic health are discussed.