Accurate subtyping of lung cancer is essential for improving patient prognosis and enabling personalized treatment. However, current clinical techniques are often time-consuming and heavily dependent on the operator's subjective judgment and experience, which limits the accuracy and timeliness of intraoperative subtype diagnosis and margin assessment. In this study, we developed an intelligent diagnostic model by integrating Fourier transform infrared (FTIR) spectroscopy with a Random Forest (RF) classifier. A total of 210 tumor and adjacent tissue samples from 105 patients, including adenocarcinoma, squamous cell carcinoma, and benign lung tumors were analyzed. The constructed RF model achieved an accuracy of 97.95% with an Area Under the Curve (AUC) of 0.99 in binary classification (lung cancer vs. adjacent tissues), and an accuracy of 94.91% in multiclass classification of lung cancer subtypes, significantly outperforming conventional algorithms such as Support Vector Machine, Naive Bayes, and Logistic Regression. In addition, spectral analysis methods, including peak area comparison, peak fitting, and second derivative analysis, revealed distinct differences in nucleic acids, proteins, and lipids, highlighting the characteristic bands responsible for subtype discrimination and providing spectroscopic insights into the pathological features of different lung cancer subtypes. Collectively, our findings demonstrate that the diagnostic model is a powerful approach for distinguishing lung cancer tissues from normal tissues and for subtype classification, offering a promising tool for lung cancer diagnosis.