Glucose homeostasis is a trait of healthy ageing and is crucial to the elderly, but less consideration has been given to the age composition in most studies involving genetics and hyperglycemia. Seven variants in FOXO3 were genotyped in three cohorts (n = 2037; LLI, MI_S and MI_N; mean age: 92.5 ± 3.6, 45.9 ± 8.2 and 46.8 ± 10.3, respectively) to compare the contribution of FOXO3 to fasting hyperglycemia (FH) between long-lived individuals (LLI, aged over 90 years) and middle-aged subjects (aged from 35-65 years). A different genetic predisposition of FOXO3 alleles to FH was observed between LLI and both of two middle-aged cohorts. In the LLI cohort, the longevity beneficial alleles of three variants with the haplotype "AGGC" in block 1 were significantly protective to FH, fasting glucose, hemoglobin A1C and HOMA-IR. Notably, combining multifactor dimensionality reduction and logistic regression, we identified a significant 3-factor interaction model (rs2802288, rs2802292 and moderate physical activity) associated with lower FH risk. However, not all of the findings were replicated in the two middle-aged cohorts. Our data provides a novel insight into the inconsistent genetic determinants between middle-aged and LLI subjects. FOXO3 might act as a shared genetic predisposition to hyperglycemia and lifespan.