Objective To explore the relationship between preoperative fasting plasma glucose (FPG) and postoperative pulmonary complications (PPCs) in type 2 diabetic patients undergoing elective thoracoscopic lung resection, and provide a reference for prediction and prevention of PPCs in the clinic. Methods A retrospective analysis was performed on the type 2 diabetic patients who underwent elective thoracoscopic lung resection for the first time in our hospital from January 2017 to March 2021. According to the level of FPG one day before the operation, the patients were divided into three groups: a hypoglycemia group (<6.1 mmol/L), a medium level blood glucose group (≥6.1 mmol/L and <8.0 mmol/L) and a high blood glucose group (≥8.0 mmol/L). Besides, the patients were divided into a PPCs group and a non-PPCs group according to whether PPCs occurred. The risk factors for PPCs were analyzed by logistic regression analysis, and the predictive value of preoperative FPG level on PPCs was estimated by the area under the receiver operating characteristic curve (AUC). Results A total of 130 patients were included, including 75 (57.7%) males and 55 (42.3%) females with an average age of 63.5±9.0 years. Logistic regression analysis showed that compared to non-PPCs patients, the level of preoperative FPG (P=0.023) and smoking history ratio (P=0.036) were higher and the operation time was longer (P=0.004) in the PPCs patients. High FPG level on preoperative day 1 and longer operation time were associated with PPCs risk. Besides, the preoperative FPG of 6.79 mmol/L was the threshold value to predict the occurrence of PPCs [AUC=0.653, 95%CI (0.559, 0.747), P=0.003]. Conclusion There is a certain correlation between preoperative FPG level and postoperative PPCs, which may be used as an index to predict the occurrence of PPCs.