Population-based studies on the mortality burden of nontuberculous mycobacteria (NTM) infection are lacking. We compared the long-term mortality of NTM-infected patients with tuberculosis (TB)-patients and the general population, and investigated mortality-associated factors. We analyzed nationwide-data from the Korean National Health Insurance and Korea-Statistical Office between 2002 and 2017. NTM infection was identified using the International Classification of Disease, Tenth Revision code, with one-to-one matching to TB patients and general population controls. A total of 530 401 individuals were analyzed, including 183 267 with NTM infections; 166 666 with TB; and 180 468 controls. The overall 6-, 10-, and 14-year cumulative survival probabilities in the NTM group were 86.3%, 80.8%, and 77.1%, respectively, which were significantly lower than those of the TB or control groups (log-rank P < .0001). In cases of NTM and TB coinfection, the overall 6-, 10-, and 14-year cumulative survival probabilities were 75.1%, 65.4%, and 57.0%, respectively. Multivariable analysis indicated that old age, male gender, province, and various respiratory or nonrespiratory comorbidities were significantly associated with mortality of NTM infection. The use of a macrolide (more than 1 year) negatively correlated with mortality of NTM infection (adjusted hazard ratio [aHR] 0.61, 95% confidence interval [CI] .53-.71), regardless of azithromycin (aHR 0.60, 95% CI .43-.85) or clarithromycin use (aHR 0.63, 95% CI .53-.75). NTM-infected patients had poor prognosis when compared to TB patients or the general population, especially for NTM and TB coinfection. NTM mortality was associated with certain demographic characteristics, but long-term use of macrolides may provide survival benefits.