With the application of low-dose computed tomography in lung cancer screening, pulmonary nodules have become increasingly detected. Accurate discrimination between primary lung cancer and benign nodules poses a significant clinical challenge. This study aimed to investigate the viability of exhaled breath as a diagnostic tool for pulmonary nodules and compare the breath test with 18F-fluorodeoxyglucose (18F-FDG) positron emission tomography (PET)–computed tomography (CT). Exhaled breath was collected by Tedlar bags and analyzed by high-pressure photon ionization time-of-flight mass spectrometry (HPPI-TOFMS). A retrospective cohort (n = 100) and a prospective cohort (n = 63) of patients with pulmonary nodules were established. In the validation cohort, the breath test achieved an area under the receiver operating characteristic curve (AUC) of 0.872 (95% CI 0.760–0.983) and a combination of 16 volatile organic compounds achieved an AUC of 0.744 (95% CI 0.7586–0.901). For PET-CT, the SUVmax alone had an AUC of 0.608 (95% CI 0.433–0.784) while after combining with CT image features, 18F-FDG PET-CT had an AUC of 0.821 (95% CI 0.662–0.979). Overall, the study demonstrated the efficacy of a breath test utilizing HPPI-TOFMS for discriminating lung cancer from benign pulmonary nodules. Furthermore, the accuracy achieved by the exhaled breath test was comparable with 18F-FDG PET-CT.