Infectious diseases caused by nontuberculous mycobacteria (NTM) are increasingly common. This retrospective cohort study examined factors associated with outcomes in patients from Shanghai who had NTM pulmonary disease (NTMPD) from January 2014 to December 2018. The causative bacterial species, drug susceptibility test results, treatment outcomes, sputum culture conversion rate, and risk factors associated with treatment failure were determined. The most common species were Mycobacterium avium complex (MAC) (50%), M. abscessus (28%), and M. kansasii (15%). Over five years, the proportions of M. kansasii and M. abscessus increased, and that of MAC decreased. The treatment success rate was significantly greater for patients infected with M. kansasii (89.9%) than MAC (65.0%, p < 0.001) and M. abscessus (36.1%, p < 0.001). Multivariate analysis indicated the risk factors for treatment failure were pathogenic NTM species (M. abscessus: aOR = 9.355, p < 0.001; MAC: aOR = 2.970, p < 0.001), elevated ESR (>60 mm/h: aOR = 2.658, p < 0.001), receipt of retreatment (aOR = 2.074, p < 0.001), and being middle-aged or elderly (>60 years-old: aOR = 1.739, p = 0.021; 45–60 years-old: aOR = 1.661, p = 0.034). The main bacterial species responsible for NTMPD were MAC, M. abscessus, and M. kansasii. Patients who were infected by M. abscessus or MAC, with elevated ESR, received retreatment, and were middle-aged or elderly had an increased risk of treatment failure.