BackgroundDiabetes is a risk factor for cognitive impairment, but whether there is also a link between pre-diabetes and cognitive dysfunction is not yet fully established. The aim of this observational study was to investigate associations between pre-diabetes/diabetes and cognitive test results, and also between glucose levels measured during the Oral Glucose Tolerance Test (OGTT) and cognitive outcomes.MethodsDuring 2007–2012, in all 2994 people (mean age 72 years), residing in Malmö, Sweden, underwent a clinical examination including the OGTT, cardiovascular measurements including carotid-femoral pulse wave velocity (c-f PWV) and two cognitive tests, the Mini Mental State Examination (MMSE), measuring global cognitive function, and A Quick Test of Cognitive Speed (AQT), measuring processing speed and executive functioning. Regression analyses were performed to investigate associations between: (a) categories of normal or impaired glucose metabolism, and (b) OGTT measurements, respectively, as exposure variables and cognitive test results as outcomes. Adjustments were made for demographics, lifestyle factors and cardiovascular risk factors.ResultsParticipants with pre-diabetes and diabetes scored slightly worse cognitive test results compared to the control group. Results of participants with a long disease duration of diabetes since the baseline examination 13 years earlier were poorer (mean AQT test time 17.8 s slower than controls, p < 0.001). Linear associations were found between fasting and 2-h glucose and cognitive outcomes in the whole population, but also in a sub-analysis including only individuals without diabetes (for 2-h glucose and MMSE results: B = − 2.961, p = 0.005). Associations were stronger for older or less physically active individuals. When adjusting for cardiovascular risk factors, most correlations were non-significant.ConclusionsPre-diabetes and diabetes are associated with minor deficits in global cognitive function, processing speed and executive functioning. Long-standing diabetes is associated with bigger deficits. There appears to be a continuous inverse correlation between glucose levels and cognitive test results, also for people without diabetes. Associations are stronger in older and less physically active individuals. Cardiovascular factors are important mediating factors in the pathway between diabetes and cognitive dysfunction.Electronic supplementary materialThe online version of this article (10.1186/s12902-018-0318-3) contains supplementary material, which is available to authorized users.