Prior studies have suggested an association between chronic pain and suicidal behavior. However, evidence supporting the causal nature of this association, and the role played by depression, remain difficult to establish due to confounding. We investigated associations of chronic pain with suicide attempt and death by suicide as well as the mediating role of depression in this association using a genetically informed method strengthening causal inference. We conducted a two-sample Mendelian randomization. Independent SNPs (N=97) from the Multisite Chronic Pain GWAS (NGWAS=387,649) were used as instrumental variables to test associations of chronic pain with suicide attempt (measured from hospital records; NGWAS=50,264) and death by suicide (measured from official death causes; NGWAS=18,085). Indirect associations of chronic pain with suicide attempt and death by suicide via major depressive disorder (NGWAS=173,005) were estimated. Primary analyses were supported by a range of sensitivity and outlier analyses.We found evidence supporting the contribution of chronic pain to increasing the risk of suicide attempt (OR=1.67, CI=1.21-2.35) and death by suicide (OR=2.00, CI=1.10-3.62). Associations were consistent across sensitivity analysis methods, and no evidence for outliers driving these associations was found. Through mediation analyses, we found that major depressive disorder explained a substantial proportion of the association between chronic pain and suicide attempt (proportion mediated=39%; ORindirect association=1.32, CI=1.09-1.61) and death by suicide (proportion mediated=34%; ORindirect association=1.40, CI=1.13-1.73). Our findings suggest that both pain management interventions and prevention of depression are likely to be effective strategies to reduce suicide risk in individuals with chronic pain.