Background: Type 2 diabetes has been inconsistently associated with the risk of atrial fibrillation (AF) in previous studies that have frequently been beset by methodological challenges. Design: Prospective cohort study. Setting: The Atherosclerosis Risk in Communities (ARIC) study. Participants: Detailed medical histories were obtained from 13 025 participants. Individuals were categorised as having no diabetes, pre-diabetes or diabetes based on the 2010 American Diabetes Association criteria at study baseline (1990-2). Main outcome measures: Diagnoses of incident AF were obtained to the end of 2007. Associations between type 2 diabetes and markers of glucose homeostasis and the incidence of AF were estimated using Cox proportional hazards models after adjusting for possible confounders. Results: Type 2 diabetes was associated with a significant increase in the risk of AF (HR 1.35, 95% CI 1.14 to 1.60) after adjustment for confounders. There was no indication that individuals with pre-diabetes or those with undiagnosed diabetes were at increased risk of AF compared with those without diabetes. A positive linear association was observed between HbA1c and the risk of AF in those with and without diabetes (HR 1.13, 95% CI 1.07 to 1.20) and HR 1.05, 95% CI 0.96 to 1.15 per 1% point increase, respectively). There was no association between fasting glucose or insulin in those without diabetes, but a significant association with fasting glucose was found in those with the condition. The results were similar in white subjects and African-Americans. Conclusions: Diabetes, HbA1c level and poor glycaemic control are independently associated with an increased risk of AF, but the underlying mechanisms governing the relationship are unknown and warrant further investigation.