Tumor necrosis factor inhibitors (TNFi) are proposed as a risk factor for nontuberculous mycobacteria (NTM) infection. Limited research investigates NTM infection risk in rheumatoid arthritis (RA) patients treated with TNFi compared to conventional synthetic disease-modifying antirheumatic drugs (csDMARDs), considering other concurrent or prior non-TNFi antirheumatic drugs. We aimed to evaluate the NTM infection risk associated with TNFi using a real-world database. Patients with RA treated with TNFi or csDMARDs between 2005 and 2016 were identified utilizing the Korean National Health Insurance Service database. To minimize potential bias, we aligned the initiation year of csDMARDs for both TNFi and csDMARD users and tracked them from their respective treatment start dates. The association of TNFi with NTM infection risk was estimated in a one-to-one matched cohort using a multivariable conditional Cox regression analysis. In the matched cohort (n = 4556), the incidence rates of NTM infection were 2.47 and 3.66 per 1000 person-year in TNFi and csDMARD users. Compared to csDMARDs, TNFi did not increase the risk of NTM infection (adjusted hazard ratio (aHR) 0.517 (95% confidence interval, 0.205–1.301)). The TNFi use in RA patients was not associated with an increased risk of NTM infection compared to csDMARDs. Nevertheless, monitoring during TNFi treatment is crucial.