Effective drugs for atrial fibrillation (AF) are lacking, resulting in significant morbidity and mortality. This study demonstrates that network proximity analysis of differentially expressed genes from atrial tissue to drug targets can help prioritize repurposed drugs for AF. Using enrichment analysis of drug-gene signatures and functional testing in human inducible pluripotent stem cell (iPSC)-derived atrial-like cardiomyocytes, we identify metformin as a top repurposed drug candidate for AF. Using the active compactor, a new design analysis of large-scale longitudinal electronic health record (EHR) data, we determine that metformin use is significantly associated with a reduced risk of AF (odds ratio = 0.48, 95%, confidence interval [CI] 0.36-0.64, p < 0.001) compared with standard treatments for diabetes. This study utilizes network medicine methodologies to identify repurposed drugs for AF treatment and identifies metformin as a candidate drug.