Abstract Background Ketone bodies (KB) are essential alternative fuel sources for the myocardium. However, the evidence on the level of circulating KB and heart disorders is inconsistent. Whether the total and individual KB are associated with risk of onset atrial fibrillation (AF) in the general population and in individuals with different genetic susceptibilities to AF are still unclear. Purpose To examine the association between circulating KB and AF risk and to further test whether genetic risk could modify the above association. Methods In the UK Biobank, 247,304 participants (mean age 56.5, 45.3% men) with available data on KB and without baseline AF were included. The concentrations of KB, including β-hydroxybutyrate (β-OHB), acetoacetate, and acetone, were measured using nuclear magnetic resonance, and the values of KB were increased by one and then log10-transformed for analyses. The genetic risk of AF was based on the standard polygenic risk score. The definitions of AF were based on the ICD-10 code I48, which was linked to primary care, hospital admission electronic health records and death records. Cox proportional hazard model was used to estimate the hazard ratio (HR) with 95% confidence interval (CI). Results During a median follow-up of 13.8 years, 16,936 cases of onset of AF were recorded. After adjusting for age, sex, race, Townsend index, education, alcohol intake frequency, smoking status, healthy diet, metabolic equivalent, body mass index, systolic blood pressure (SBP), total cholesterol, estimated glomerular filtration rate, cardiovascular diseases, and diabetes, elevated total KB, β-OHB, acetoacetate, and acetone were all with the risk of AF (HR, 95% CI per 10-fold increase: 1.20, 1.13-1.28; 1.13, 1.07-1.19; 1.12, 1.06-1.18; and 1.78, 1.57-2.01, respectively). The highest risk of AF was observed among individuals at high genetic risk to AF and had the highest quartile of total KB (HR 2.91, 95% CI 2.66-3.19). Participants who had low genetic risk were more susceptible to high total KB for incident AF (p for interaction = 0.036). The associations of total KB, β-OHB, and acetone with AF risk were more prominent for men (HR, 95% CI per 10-fold increase: 1.32, 1.22-1.44; 1.22, 1.14-1.31; 2.01, 1.72-2.36) than for women (p for interaction <0.05). The association between total KB and AF risk was strengthened in individuals <60 years, current smokers, and those with SBP<130 mmHg (p for interaction = 0.033, 0.021, and 0.017, respectively). Conclusions Circulating KB concentrations were associated with AF risk, with acetone showing the strongest relationship with AF. Individuals at low genetic risk were more susceptible to the level of total KB for incident AF. Our findings suggest that KB may be a biomarker, particularly for identifying individuals without AF at baseline who are at low genetic risk. The additive value of plasma KB to a risk prediction score warrants further investigation.