BACKGROUND In population studies, mild hypomagnesemia, determined by a single measurement, was associated with incident atrial fibrillation, over ~20 years of follow-up. We sought to determine whether mild (≤ 1.7 mg/dL) and moderate (≤ 1.5mg/dL) hypomagnesemia are temporally associated with increased incidence of atrial fibrillation (AF) in the community. METHODS Health Maintenance Organization (HMO) database cohort study including beneficiaries with ≥ 1 serum magnesium measurement between 2004 and 2013. The follow-up period was defined from the first magnesium measurement to first listing in an AF registry (for cases) and December 2013 or date of death or loss to follow-up (for controls). We analyzed the association between serum magnesium quintiles, as well as the above clinically relevant hypomagnesemia thresholds, and incident AF using Cox proportional hazard regression analysis, adjusting for confounders. The association between serum magnesium and AF occurring within 3 months was also examined. RESULTS Among 162,162 subjects, 2228 (1.4%) developed AF over a median follow-up of 25.3 months. Compared to the middle quintile the lowest magnesium quintile (≤ 1.9 mg/dL) had a significantly higher risk of AF (HR, 1.21; 95% CI: 1.07-1.37). Increased AF risk was also associated with mild (HR, 1.44; 95% CI: 1.20-1.73) and moderate hypomagnesemia (HR, 1.57; 95% CI: 1.14-2.15). No association was found when limiting the follow-up period to 3 months. CONCLUSIONS In our study, hypomagnesemia was associated with incident AF over prolonged but not short-term follow-up periods, suggesting that this association may not be causal.