Background: Erectile dysfunction is one of many conditions associated with depression, but few studies exist to establish the risk of major depressive disorder (MDD) in the large population of men with erectile dysfunction, and it is unclear whether erectile dysfunction (ED) treatment is associated with decreased rates of MDD. Aim: We determined the risk of major depressive disorder in men with erectile dysfunction and evaluated whether treatment of ED with phosphodiesterase-5 inhibitor or penile prosthesis is associated with a lower risk of developing major depressive disorder. Methods: We reviewed a large, retrospective, cohort that utilized electronic health record data collected by the TriNetX Research Network, a global federated database that provides healthcare data for analysis. We performed multiple comparisons: men with ED against men without ED; men with ED treated with phosphodiesterase-5 inhibitors against untreated ED patients, and of men with ED who received penile prosthesis against those who did not. We assessed major depressive disorder (ICD-10-CM F32-F33) as a primary outcome and used propensity score matching to control for ethnicity, race, type 2 diabetes mellitus (E11), essential hypertension (I10), acute myocardial infarction (I21), chronic ischemic heart disease (I25), cerebral infarction (I63), overweight and obesity (E66), personal history of nicotine (Z87.891), hypogonadism (E29.1), and alcohol related disorders (F10). Outcomes: We assessed new diagnosis of major depressive disorder (F32-F33) within a 3-year time window following index event of ED diagnosis, visit to healthcare organization, or ED treatment with phosphodiesterase-5 inhibitor or penile prosthesis as the primary outcome. Results: ED was associated with major depressive disorder both before and after (OR 2.00, 95% CI 1.94-2.06) controlling for confounding variables through propensity score matching. Men who received ED therapies had lower rates of depression compared to those who did not, whether they were treated with phosphodiesterase-5 inhibitor (0.80, 0.77-0.83) or penile prosthesis (0.73, 0.60-0.89). Strengths and Limitations: Strengths include a large sample size and robust statistical techniques. Limitations include lack of detailed information regarding clinical severity and socioeconomic factors. Clinical Implications: Our findings indicate that clinicians should consider evaluating depressive symptoms among men with erectile dysfunction and counsel them regarding the risk of developing major depressive disorder. Conclusions: Erectile dysfunction is associated with major depressive disorder, but treatment is associated with decreased rates of MDD. Copyright (C) 2021, International Society of Sexual Medicine. Published by Elsevier Inc. All rights reserved.