Background The Xpert MTB/RIF assay is an automated molecular test that has improved the detection of tuberculosis and rifampicin resistance, but its sensitivity is inadequate in patients with paucibacillary disease or HIV. Xpert MTB/RIF Ultra (Xpert Ultra) was developed to overcome this limitation. We compared the diagnostic performance of Xpert Ultra with that of Xpert for detection of tuberculosis and rifampicin resistance. Methods In this prospective, multicentre, diagnostic accuracy study, we recruited adults with pulmonary tuberculosis symptoms presenting at primary health-care centres and hospitals in eight countries (South Africa, Uganda, Kenya, India, China, Georgia, Belarus, and Brazil). Participants were allocated to the case detection group if no drugs had been taken for tuberculosis in the past 6 months or to the multidrug-resistance risk group if drugs for tuberculosis had been taken in the past 6 months, but drug resistance was suspected. Demographic information, medical history, chest imaging results, and HIV test results were recorded at enrolment, and each participant gave at least three sputum specimen on 2 separate days. Xpert and Xpert Ultra diagnostic performance in the same sputum specimen was compared with culture tests and drug susceptibility testing as reference standards. The primary objectives were to estimate and compare the sensitivity of Xpert Ultra test with that of Xpert for detection of smear-negative tuberculosis and rifampicin resistance and to estimate and compare Xpert Ultra and Xpert specificities for detection of rifampicin resistance. Study participants in the case detection group were included in all analyses, whereas participants in the multidrug-resistance risk group were only included in analyses of rifampicin-resistance detection. Findings Between Feb 18, and Dec 24, 2016, we enrolled 2368 participants for sputum sampling. 248 participants were excluded from the analysis, and 1753 participants were distributed to the case detection group (n=1439) and the multidrug-resistance risk group (n=314). Sensitivities of Xpert Ultra and Xpert were 63% and 46%, respectively, for the 137 participants with smear-negative and culture-positive sputum (difference of 17%, 95% CI 10 to 24); 90% and 77%, respectively, for the 115 HIV-positive participants with culture-positive sputum (13%, 6·4 to 21); and 88% and 83%, respectively, across all 462 participants with culture-positive sputum (5·4%, 3·3 to 8·0). Specificities of Xpert Ultra and Xpert for case detection were 96% and 98% (−2·7%, −3·9 to −1·7) overall, and 93% and 98% for patients with a history of tuberculosis. Xpert Ultra and Xpert performed similarly in detecting rifampicin resistance. Interpretation For tuberculosis case detection, sensitivity of Xpert Ultra was superior to that of Xpert in patients with paucibacillary disease and in patients with HIV. However, this increase in sensitivity came at the expense of a decrease in specificity. Funding Government of Netherlands, Government of Australia, Bill & Melinda Gates Foundation, Government of the UK, and the National Institute of Allergy and Infectious Diseases.