Atrial fibrillation (AF) is associated with an increased risk of myocardial infarction (MI) and vice versa. This bidirectional association relies on shared risk factors as well as on several direct and indirect mechanisms, including inflammation, atrial ischaemia, left ventricular remodelling, myocardial oxygen supply-demand mismatch and coronary artery embolism, through which one condition can predispose to the other. Patients with both AF and MI are at greater risk of stroke, heart failure and death than patients with only one of the conditions. In this Review, we describe the bidirectional association between AF and MI. We discuss the pathogenic basis of this bidirectional relationship, describe the risk of adverse outcomes when the two conditions coexist, and review current data and guidelines on the prevention and management of both conditions. We also identify important gaps in the literature and propose directions for future research on the bidirectional association between AF and MI. The Review also features a summary of methodological approaches for the study of bidirectional associations in population-based studies.