Importance: Inflammatory bowel disease (IBD) is commonly treated with corticosteroids and anti-tumor necrosis factor (TNF) drugs; however, medications have well-described adverse effects. Prior work suggests that anti-TNF therapy may reduce all-cause mortality compared with prolonged corticosteroid use among Medicare and Medicaid beneficiaries with IBD. Objective: To examine the association between use of anti-TNF or corticosteroids and all-cause mortality in a national cohort of veterans with IBD. Design, Setting, and Participants: This cohort study used a well-established Veteran's Health Administration cohort of 2997 patients with IBD treated with prolonged corticosteroids (≥3000-mg prednisone equivalent and/or ≥600 mg of budesonide within a 12-month period) and/or new anti-TNF therapy from January 1, 2006, to October 1, 2015. Data were analyzed between July 1, 2019, and December 31, 2020. Exposures: Use of corticosteroids or anti-TNF. Main Outcomes and Measures: The primary end point was all-cause mortality as defined by the Veterans Health Administration vital status file. Marginal structural modeling was used to compare associations between anti-TNF therapy or corticosteroid use and all-cause mortality. Results: A total of 2997 patients (2725 men [90.9%]; mean [SD] age, 50.0 [17.4] years) were included in the final analysis, 1734 (57.9%) with Crohn disease (CD) and 1263 (42.1%) with ulcerative colitis (UC). All-cause mortality was 8.5% (n = 256) over a mean (SD) of 3.9 (2.3) years' follow-up. At cohort entry, 1836 patients were new anti-TNF therapy users, and 1161 were prolonged corticosteroid users. Anti-TNF therapy use was associated with a lower likelihood of mortality for CD (odds ratio [OR], 0.54; 95% CI, 0.31-0.93) but not for UC (OR, 0.33; 95% CI, 0.10-1.10). In a sensitivity analysis adjusting prolonged corticosteroid users to include patients receiving corticosteroids within 90 to 270 days after initiation of anti-TNF therapy, the OR for UC was statistically significant, at 0.33 (95% CI, 0.13-0.84), and the OR for CD was 0.55 (95% CI, 0.33-0.92). Conclusions and Relevance: This study suggests that anti-TNF therapy may be associated with reduced mortality compared with long-term corticosteroid use among veterans with CD, and potentially among those with UC..