OBJECTIVE: To investigate the role of low serum magnesium as a trigger for atrial fibrillation in patients with a substrate for the arrhythmia (assessed by signal averaged P wave duration). DESIGN: A case-control study. SETTING: A regional referral cardiac centre. PATIENTS AND INTERVENTIONS: 105 consecutive patients undergoing elective coronary artery bypass surgery had signal averaged P wave recordings before operation. Serum electrolytes were analysed preoperatively and on days 1, 2, and 5 after surgery. MAIN OUTCOME MEASURES: Any episode of electrocardiographically recorded atrial fibrillation was taken as a study end point. RESULTS: Of 102 patients discharged, 27 (26%) had documented episodes of atrial fibrillation at a mean of 2.7 days after surgery. A combination of P wave duration > 155 ms and serum magnesium on the first postoperative day of < 0.7 mmol/l had a sensitivity of 75% and specificity of 80% for predicting atrial fibrillation. Duration of hospital stay (7.9 v 6.8 days) was longer in the atrial fibrillation group (P < 0.01). Stepwise regression showed age, serum magnesium < 0.7 mmol/l on the first postoperative day (both P < 0.001), angiotensin converting enzyme inhibitor withdrawal (P < 0.02), and signal averaged P wave duration (P = 0.04) to be independent predictors. CONCLUSIONS: The combination of signal averaged P wave duration and low serum magnesium on the first postoperative day identified the majority of patients with atrial fibrillation after coronary artery bypass surgery. Early identification and pharmacological treatment for selected patients may reduce the incidence of postoperative atrial fibrillation.