Lung cancer is the leading cause of cancer death. For malignant pleural effusions, pleural fluid cytology is a diagnostic method, but sensitivity is low. Many patients need to undergo invasive diagnostic tests such as thoracoscopic pleural biopsy. Pleural space is an enclosed microenvironment, and the pleural fluid contains metabolites directly released from cancer cells. The objective of this study was to diagnose lung cancer with malignant pleural effusion using the volatilomic profiling method. We recruited lung cancer patients with malignant pleural effusion and patients with nonmalignant diseases with pleural effusion as controls. We analyzed the headspace air of the pleural effusion by gas chromatography-mass spectrometry. We used partial least squares discriminant analysis (PLS-DA) to identify metabolites and the support vector machine (SVM) to establish the prediction model. We split data into a training set (80%) and a testing set (20%) to validate the accuracy. A total of 68 subjects were included in the final analysis. The PLS-DA showed high discrimination with an R2 of 0.95 and Q2 of 0.58. The accuracy of the SVM in the test set was 0.93 (95% CI: 0.66, 0.998), and kappa was 0.85, and the area under the receiver operating characteristic curve was 0.96 (95% CI: 0.86, 1.00). Pathway analysis revealed disturbances in pyruvate metabolism, the tricarboxylic acid, glycolysis, and lysine degradation. The volatile metabolites identified from malignant pleural effusion of lung cancer were primarily methylated alkanes. The pleural effusion contained volatile metabolites that have high accuracy in diagnosing lung cancer with malignant pleural effusion.