Importance: Concerns have been raised since the onset of the COVID-19 pandemic that vulnerable populations, such as military veterans, may be at increased risk of suicidal thoughts and behaviors (STBs). Objective: To examine longitudinal trends in STBs in US military veterans during the first 3 years of the COVID-19 pandemic. Design, setting, and participants: This cohort study is a population-based longitudinal study including US military veterans that used 3 surveys from the National Health and Resilience in Veterans Study. Median dates of data collection were November 21, 2019 (prepandemic); November 14, 2020; and August 18, 2022. Main outcomes and measures: Lifetime and past-year suicidal ideation, suicide planning, and suicide attempt. Results: In this longitudinal study including 2441 veterans (mean [SD] age, 63.2 years [14.0]; 2182 [92.1%] male), past-year suicidal ideation decreased from 9.3% prepandemic (95% CI, 8.2%-10.6%) to 6.8% a year later (95% CI%, 5.8-7.9%) and then slightly increased to 7.7% (95% CI, 6.7%-8.9%) 2 years later. In total, 9 veterans (0.4%) reported attempting suicide at least once during the follow-up period, while 100 (3.8%) developed new-onset suicidal ideation and 28 (1.2%) developed new-onset suicide planning. After adjusting for sociodemographic and military characteristics, factors strongly associated with new-onset suicidal ideation included higher education (odds ratio [OR], 3.27; 95% CI, 1.95-5.46), lifetime substance use disorder (OR, 2.07; 95% CI, 1.23-3.46), prepandemic loneliness (OR, 1.28; 95% CI, 1.09-1.49), and lower prepandemic purpose in life (OR, 0.92; 95% CI, 0.86-0.97). Factors associated with new-onset suicide planning included lifetime substance use disorder (OR, 3.03; 95% CI, 1.22-7.55), higher prepandemic psychiatric distress (OR, 1.52; 95% CI, 1.06-2.18), and lower prepandemic purpose in life (OR, 0.88; 95% CI, 0.81-0.95). Conclusions and relevance: Contrary to expectations, the prevalence of STBs did not increase for most US veterans during the COVID-19 pandemic. However, veterans with preexisting loneliness, psychiatric distress, and lower purpose in life were at heightened risk of developing new-onset suicidal ideation and suicide planning during the pandemic. Evidence-based prevention and intervention efforts that target these factors may help mitigate suicide risk in this population.